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'))
3 Comments
Filed under:
DBA Toolbox / T-SQL Scripts, T-SQL Tips and Tricks