If you want to list the definition for a stored procedure, User Defined Function, or Trigger, you can use one of the following ways:

Alternative 1: sp_helptext (T-SQL)

-- using sp_helptext
sp_helptext 'dbo.your_object_name'

Alternative 2: syscomments (T-SQL)

-- using syscomments
SELECT  
FROM sys.syscomments
WHERE OBJECT_NAME(id) = 'your_object_name'

Alternative 3: OBJECT_DEFINITION (T-SQL)

-- using built in function OBJECT_DEFINITION
SELECT OBJECT_DEFINITION(OBJECT_ID('your_object_name'))
VN:F [1.9.22_1171]
Rating: 8.9/10 (18 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
How to Get Definition for Stored Procedures, UDFs and Triggers using T-SQL, 8.9 out of 10 based on 18 ratings  
Be Sociable, Share!
  • Tweet