Search code examples
sql-serverfunctionsql-server-2005

View all functions from the SQL Server database?


How can I view all the functions (built in) in a SQL Server database using SQL Server Management Studio?


Solution

  • This will return all user-defined functions. I'm not sure what you mean by "build-in" functions.

    SELECT * 
    FROM sys.objects 
    WHERE RIGHT(type_desc, 8) = 'FUNCTION'
    

    OR

    SELECT * FROM sys.all_objects where type in ('FN','AF','FS','FT','IF','TF')
    

    Here are the types:

    --AF = Aggregate function (CLR)
    --C = CHECK constraint
    --D = DEFAULT (constraint or stand-alone)
    --F = FOREIGN KEY constraint
    --PK = PRIMARY KEY constraint
    --P = SQL stored procedure
    --PC = Assembly (CLR) stored procedure
    --FN = SQL scalar-function
    --FS = Assembly (CLR) scalar function
    --FT = Assembly (CLR) table-valued function
    --R = Rule (old-style, stand-alone)
    --RF = Replication filter procedure
    --SN = Synonym
    --SQ = Service queue
    --TA = Assembly (CLR) trigger
    --TR = SQL trigger 
    --IF = SQL inlined table-valued function
    --TF = SQL table-valued function
    --U = Table (user-defined)
    --UQ = UNIQUE constraint
    --V = View
    --X = Extended stored procedure
    --IT = Internal table
    

    Here is a list of all system stored procs:

    http://msdn.microsoft.com/en-us/library/ms187961.aspx