SQL Server - where is “sys.functions”?

后端 未结 10 1288
天命终不由人
天命终不由人 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 10:05

    For a fuller description of scalar functions including owner and return type:

    SELECT f.name, s.name AS owner, t.name as dataType, p.max_length, p.precision, p.scale, m.definition
    FROM sys.objects f
    JOIN sys.schemas s on s.schema_id = f.schema_id
    JOIN sys.parameters p on p.object_id = f.object_id AND p.parameter_id = 0
    JOIN sys.types t ON t.system_type_id = p.system_type_id 
    JOIN sys.sql_modules as m ON m.object_id = f.object_id
    WHERE type='FN';
    
    0 讨论(0)
  • 2020-12-04 10:07

    It's very slightly more verbose, but this should do exactly the same thing:

    select * from sys.objects where (type='TF' or type='FN')
    

    As far as I can see, it's not in SQL Server 2008 either.

    0 讨论(0)
  • 2020-12-04 10:14

    SQL 2000 specific, slight adjustment for the object name:

    SELECT *
    FROM sysobjects
    WHERE type IN ('FN', 'IF', 'TF')
    

    OR

    SELECT *
    FROM dbo.sysobjects
    WHERE type IN ('FN', 'IF', 'TF')
    
    0 讨论(0)
  • 2020-12-04 10:19

    This is valid in 2008 R2 per what SSMS generates when you script a DROP of a function:

    SELECT  *
    FROM    sys.objects
    WHERE   type IN (N'FN', N'IF', N'TF', N'FS', N'FT') ;
    
    /*
    From http://msdn.microsoft.com/en-us/library/ms177596.aspx:
     FN SQL_SCALAR_FUNCTION
     FS Assembly (CLR) scalar-function
     FT Assembly (CLR) table-valued function
     IF SQL_INLINE_TABLE_VALUED_FUNCTION
     TF SQL_TABLE_VALUED_FUNCTION
    */
    
    0 讨论(0)
提交回复
热议问题