This is quick but interesting trick to display the text of Stored Procedure in the result window. Open SQL Query Analyzer >> Tools >> Customize >> Custom Tab
type sp_helptext against Ctrl+3 (or shortcut key of your choice)
Press CTRL + T to enable the text view in result window.
Type any Stored Procedure name in your database, select the SP name and type Ctrl+4.
You will see the Stored Procedure text in the Result Window.
As SQL Server 2005 and onwards version of SQL Server now uses Management Studio instead of query analyzer.
Here are additional blog posts related to the this blog:
- SQL SERVER – SP to display code (text) of SP, Trigger, View or Object
- SQL SERVER – Simple Use of Cursor to Print All SP of Database
- SQL SERVER – sp_HelpText for sp_HelpText – Puzzle
- Fastest Way to Display Code of Any SP – Interview Question of the Week #094
Let us see the fastest way to display code of the SP.
First, go to SQL Server Management Studio and select option Results to Text (shortcut CTRL+T).
Next type following script in Query Editor and hit execute. Do not forget to replace the string ‘NameofYourSP’ with the name of your actual stored procedure.
Reference: Pinal Dave (http://www.SQLAuthority.com)