Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL database in Microsoft Fabric
This article describes how to view the definition of procedure in Object Explorer or T-SQL.
To view the definition a procedure in Object Explorer:
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 select Script Stored Procedure as, and then select one of the following: Create To, Alter To, or Drop and Create To.
Select New Query Editor Window. This will display the procedure definition.
In T-SQL, you can use one of the following three commands:
Note
The system stored procedure sp_helptext
is not supported in Azure Synapse Analytics. Instead, use sys.sql_modules
object catalog view.
In Object Explorer, connect to an instance of the Database Engine.
On the toolbar, select 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.
USE AdventureWorks2022;
GO
EXEC sp_helptext N'AdventureWorks2022.dbo.uspLogError';
In Object Explorer, connect to an instance of the Database Engine.
On the toolbar, select New Query.
In the query window, enter the following statements that use the OBJECT_DEFINITION
system function. Change the database name and stored procedure name to reference the database and stored procedure that you want. This query leverages OBJECT_ID and OBJECT_DEFINITION to identify the object by its three-part name.
USE AdventureWorks2022;
GO
SELECT OBJECT_DEFINITION (OBJECT_ID(N'AdventureWorks2022.dbo.uspLogError'));
In Object Explorer, connect to an instance of the Database Engine.
On the toolbar, select New Query.
In the query window, enter the following statements that use the sys.sql_modules
catalog view. Change the database name and stored procedure name to reference the database and stored procedure that you want.
USE AdventureWorks2022;
GO
SELECT [definition]
FROM sys.sql_modules
WHERE object_id = (OBJECT_ID(N'dbo.uspLogError'));
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today