How to view the stored procedure code in SQL Server Management Studio

I guess this is a better way to view a stored procedure's code:

sp_helptext <name of your sp>

Right click on the stored procedure and select Script Stored Procedure as | CREATE To | New Query Editor Window / Clipboard / File.

You can also do Modify when you right click on the stored procedure.

For multiple procedures at once, click on the Stored Procedures folder, hit F7 to open the Object Explorer Details pane, hold Ctrl and click to select all the ones that you want, and then right click and select Script Stored Procedure as | CREATE To.


The option is called Modify:

enter image description here

This will show you the T-SQL code for your stored procedure in a new query window, with an ALTER PROCEDURE ... lead-in, so you can easily change or amend your procedure and update it


This is another way of viewing definition of stored procedure

SELECT OBJECT_DEFINITION (OBJECT_ID(N'Your_SP'))