Search this blog

Wednesday, June 10, 2009

Lists All StoredProcedure, Function and its Definition

The following Query helps to get the lists of Procedure name and its definition(T-SQL) by single query

SELECT

SysObj.Name as Proc_Name,

SM.[definition] as Proc_TSQL

FROM

SYS.SQL_MODULES SM INNER JOIN sys.objects SysObj

ON SM.OBJECT_ID = SysObj.OBJECT_ID

WHERE SysObj.type = 'P'

To lists All the Function name and its Definition, use "SysObj.type = 'IF'" as follows:

SELECT

SysObj.Name as Proc_Name,

SM.[definition] as Proc_TSQL

FROM

SYS.SQL_MODULES SM INNER JOIN sys.objects SysObj

ON SM.OBJECT_ID = SysObj.OBJECT_ID

WHERE SysObj.type = 'IF'


This query request will looks as shown in the exhibit

No comments:

Post a Comment