Jay Parihar
SQL Server March 2, 2017

Get the Stored procedure Definition using Query

Using SQL Server Management Studio 

To view the definition a procedure in Object Explorer, connect to an  instance of Database Engine and then expand that Instance. Expand Databases, expand the database in which the procedure belongs, and then expand Programmability. Expand Stored Procedures, right-click the procedure and then click Script Stored Procedure as, and then click one of the following: Create To, Alter To, or Drop and Create To. Select New Query Editor Window. This will display the procedure definition.


Using Transact-SQL

To view the definition of a procedure in Query Editor System Stored Procedure: sp_helptext In Object Explorer, connect to an instance of the Database Engine. On the toolbar, click New Query. In the query window, enter the following statement that uses the sp_helptext system stored procedure. Change the database name and stored procedure name to reference the database and stored procedure that you want.



Leave a Reply

Your email address will not be published. Required fields are marked *