Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am new to SQL Server. I am logged into my database through SQL Server Management Studio.

I have a list of stored procedures. How do I view the stored procedure code?

Right clicking on the stored procedure does not have any option like view contents of stored procedure.

Thanks.

like image 917
DG3 Avatar asked Jan 04 '12 19:01

DG3


People also ask

Where the code of stored procedure is saved?

A stored procedure is a set of Structured Query Language (SQL) statements with an assigned name, which are stored in a relational database management system (RDBMS) as a group, so it can be reused and shared by multiple programs.


2 Answers

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

sp_helptext <name of your sp> 
like image 141
Kniganapolke Avatar answered Oct 24 '22 21:10

Kniganapolke


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.

like image 41
SQLMenace Avatar answered Oct 24 '22 20:10

SQLMenace