SQL Server - where is “sys.functions”?

后端 未结 10 1350
天命终不由人
天命终不由人 2020-12-04 09:15

SQL Server 2005 has great sys.XXX views on the system catalog which I use frequently.

What stumbles me is this: why is there a sys.procedures

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 09:59

    To extend upon @LukeH's answer, to return the function definitions as well requires a join to the sys.sql_modules table. So the query for this is:

    SELECT O.name as 'Function name', M.definition as 'Definition', O.object_id
    FROM sys.objects as O INNER JOIN sys.sql_modules as M
        ON O.object_id = M.object_id
    WHERE type IN ('FN', 'IF', 'TF')  -- scalar, inline table-valued, table-valued
    

    where the above displays the function name, its definition and the object identifier respectively.

提交回复
热议问题