SQL Prompt - 5.3
Encapsulating SQL as a new stored procedure - SQL Prompt
SQL Prompt allows you to create a new stored procedure from any block of valid SQL.
Note: Encapsulating SQL as a new stored procedure is available only in SQL Prompt Pro Edition.
To encapsulate SQL as a new stored procedure:
- Open the SQL script you want to encapsulate in a query window.
- Select the section of the script that you want to use for the new stored procedure.
Parameters are created from variables in the script, therefore it is recommended that you declare any variables in the SQL you select.
Note that if there are syntax errors in the SQL you select, SQL Prompt cannot create a new stored procedure.
- On the SQL Prompt menu, click Encapsulate As New Stored Procedure.
The Encapsulate As New Stored Procedure wizard is displayed:

- In the Owner box, type the name of the owner for the new stored procedure.
- In the Name box, type a name for the new stored procedure.
Note that SQL Prompt does not check for duplicate names. If a stored procedure with this owner and name already exists, the SQL script to create the new stored procedure will fail when you run it.
Variables that will be used to create parameters are listed in the Parameters box. SQL Prompt automatically determines whether each variable will be an input parameter or an output parameter.
- In the Parameters box, reorder the parameters as required using the
and
buttons.If a
warning triangle is displayed by a parameter, move your mouse over the warning triangle to see details of the warning.The SQL script to create the new stored procedure is displayed in the Preview box.
- Click Next.
The second page of the wizard is displayed:

- If you do not want the new stored procedure to replace the SQL you selected, under Source script, select Do not modify.
The Preview box now displays the SQL you selected, and shows how it will be modified if you chose to replace it with a reference to the new stored procedure.
- Click View Script.
The SQL script to create the stored procedure is displayed in a new query window.
If you selected Modify to reference the new stored procedure, SQL Prompt replaces the SQL you selected with a reference to the new stored procedure.
- Edit the stored procedure creation script if required, and run it.
The new stored procedure is created.
Was this article helpful?
SQL Prompt
- SSMS failed to load SQL Prompt add-in 80070002
- No SQL Prompt menu appears in Query Analyzer
- SQL Prompt is showing an old version of my stored procedure (version 3)
- Removing menu items after uninstalling SQL Prompt and SQL Refactor
- A newly-created table exists, but it is not visible in the candidate list (version 3)
- Configuring permissions for SQL Prompt
- Using Intellisense or auto complete with a VS Web project (version 3.5)
- Uninstalling the Visual Studio 2005 add-in
- Unable to cast object of type 'System.DBNull' to type 'System.String' (version 3)
- Suggestions to improve performance for pre-formatted SQL (version 3.9)
- Changing the location of the settings, cache files and snippets folders
- Saving SQL Prompt options (version 3)
- SQL 2008 installation fails with Express Tools rule (version 3.8)
- Add-in failing to load into SQL Server Management Studio on Vista
- Removing SQL Server Management Studio Integration after uninstallation
- Layout SQL Error
- Downgrading to SQL prompt 3.9 from 4.0
- Candidate suggestions being displayed slowly
- SQL Prompt is not showing all linked servers
- Log files
- Refreshing the cache
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Prompt
- Activating your products
- Activating your products
- Getting help offline
- Customizing SQL Prompt to write SQL code more efficiently
- SQL Prompt 3.xx - reducing memory usage to improve performance
- Using SQL Prompt 4: tips for SQL Prompt 3 users
- SQL Prompt release notes - version 4.xx
- Release notes - version 5.xx
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Using SQL Prompt