SQL SERVER – Query Analyzer Short Cut to display the text of Stored Procedure

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:

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).

SQL SERVER - Query Analyzer Short Cut to display the text of Stored Procedure displayspcode1

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)

SQL Server, SQL Server Management Studio, SQL Shortcut, SQL Stored Procedure
Previous Post
SQL SERVER – SQL Joke, SQL Humor, SQL Laugh
Next Post
SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case

Related Posts

34 Comments. Leave new

  • Prashant Pandey
    September 17, 2007 1:11 am

    Nice trick for shortcut of sp_helptext. :)

  • Is there any trick to do this in SQl Server Management Studio ??

    There’s something to define shortcuts but it doesn’t work !!

    I think we have to add something to indicate the selected text is the parameter of sp_helptext… but don’t know what !!


  • Fergus Bown
    July 28, 2008 8:27 pm

    In answer to Hollywood, the shortcuts thing (Tools | Options | Environment | Keyboard) does work, you just have to restart Management Studio before it recognizes the shortcut. It then takes the selected text as the parameter automatically

  • This is useful, but it’s something I am aware of. Call me lazy, but what I am looking for is a way to output the text (code) of a stored procedure in Text mode (results to text) in the Management Studio of SQL Server 2005. I can currently do this by a combination of Ctrl+T and Ctrl+F1 (which I’ve assigned to sp_helptext). Is there any way to achieve both actions using a single keyboard shortcut?

  • Hi
    This is prabu really am enjoying your reply its simply good and i have a issue

    This is am trying to use query shortcut i assigned the query for the short cut actually what i did is

    1. Option -> Enviroinment -> Keyoard and then i set

    ctrl +3 =Select * from
    2.Then i come back to query window and selected a table and then i hit ctrl +3 but it dosen’t show anything if you help me for this its really usefull for me

    thanks in advance

  • Praburaj, you have to close and re-open management studio for it to “take”.

  • Hi,
    I’m using sql 2008. ctrl+ F is not working.
    even selecting find option from the edit menu is not working.
    if i select the ctrl+tab it shows the active window for find option , but selecting it doesnt show the find window.

  • once i closed my sql my short cut’s are deleted ,
    i need to keep this ,,
    is this possible

  • I’m using QA2000 and I set the procedure sp_helptext on Ctrl+3 shortcut, for example, and on editor pane I selected (highlighted) a procedure name (salesbycategory on Northwind database) and pushed Ctrl+3, but I got the following error:

    Server: Msg 201, Level 16, State 3, Procedure sp_helptext, Line 0
    Procedure ‘sp_helptext’ expects parameter ‘@objname’, which was not supplied.

    How can I use a shortcut (sp_helptext) and set an argument (salesbycategory) for it?


  • keyboards>> ctrl+3 = sp_helptext

    If you need to see the procedure means just give the procedurename



    select above procedure and press ctrl+3 it will work perfect…

  • Hi

    I need to set Select * from to ctrl+3

    I have select the tablename by using ctrl+3

    it shows

    Incorrect syntax near ‘From’. this issue…

    Help me…


  • Hi, I have the same problem with management studio 2005. I have ctrl+3 shortcut assigned to “SELECT * FROM “. I open new query window run shortcut and I get the message Incorrect syntax near ‘FROM’.

    It looks like the shortcut doesn’t pass the selected value.

    Someone, Please help!!!

  • it used to work for me in xp, no longer working in windows 7, anyone knows why? :(

  • Is there any short cut key for comment and uncommment the line.

    thanks in advance


  • Hi,

    Could you tell me, how can i know the SQL server functions like sp_helptext?


  • Kirti Darji
    June 8, 2011 8:52 pm

    Windows 7 with keyboard short cut for SQL server 2005 It does not work any reference for that

    Thank You
    Kirti Darji

  • kuldeep singh
    March 24, 2012 11:14 am

    what is short cut for Funtion dispaly in text

  • How to create shortcut for procedure which takes more than one argument?

    • Do you mean you want to skip passing values for some parameters?

      • yes this can be a case but I want to create shortcut for a procedure which takes more than one parameter. suppose I have a procedure which returns records based on two filter conditions and user has to pass that two values.

        exec myProc @parm1=value1, @parm2=value2

        One more thing how to create shortcut for followinw query
        select top 10 * from where RowStatus=1

        where RowStatus is

  • Hi, i tried with the shortcut and i worked bu on problem – it is working for procedures (like sp_help) but not working for procs which are under a schema, any help

    • Unfortunately for schema objects you have to surround the fully qualified name with tick marks, select all of that and then hit your hotkey: ‘schema.myObject’ <<–like so.

  • Tools >>Options>> Environment>>KeyBoard
    set the specific key to shortcut then easy to get the data or insert or update with out writing all the syantax

    Thanks a lot


Leave a ReplyCancel reply

Exit mobile version