Today, I received a task to alter a number of stored procedures and create its “alter” script. So if you need to alter the script, you need to either right click on database>> stored procedure and filter the stored procedure and then create its alter script or add sp_helptext before any stored procedure to get its script. I normally prefer to go with the second option.

However, if you need to get the script of stored procedure, you need to write “sp_helptext” as many times as you need the script of stored procedure. Here is the solution.

You simply need to add a shortcut in SQL Server and have fun.

But the question is how to do it?

Lets proceed step by step.

Step 1 :
Go to Tools >> Options >> and in the Options you need to go to Environment >> Keyboard
and set “Sp_helptext” in front of “Ctrl+F1”. Meaning, whenever you press “Ctrl+F1” it will work like “Sp_helptext”

Step 2 :
Now, write any stored procedure and press “Ctrl+F1”. Ooops….. It’s not working.
So, it will not work in the already opened window. Open a new window, then connect the SSMS again and try to use it. This time it will work.

For example : Write any stored procedure and press “Ctrl+F1”. It will give you its script.

Now, my purpose is resolved but I was thinking that whenever I need to browse a table I need to write “Select * from” + TableName.
So why not we add this one also in the shortcut.

Lets do it and review the impact.
Now add “Select * from” in front of “Ctrl+3”

Now, open a new window again and type any table name and press “Ctrl+3”

Now you can browse any table without writing “Select * from”

Read Full Post »