Interpreting type codes in sys.objects in SQL Server

前端 未结 3 1208
慢半拍i
慢半拍i 2021-02-01 08:02

On SQL Server, the sys.objects table includes \"Type\" and \"Type_Desc\" attributes. For example, for one of my DBs:

SELECT DISTINCT [Type], Type_Desc
FROM Sys.O         


        
相关标签:
3条回答
  • 2021-02-01 08:17

    For SQL 2016 this is new:

    SP = Security Policy
    
    0 讨论(0)
  • 2021-02-01 08:18

    BOL has a complete list, but you can't join on that.

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

    Going to the best SQL Server source for this info: sys.objects (Transact-SQL) it doesn't mention any table to join to. I can't say that I have ever noticed a codes table to join to for any of the systems tables or views.

    I guess you'll have to create your own table or view, or just use the Type_Desc attribute in sys.objects.

    0 讨论(0)
  • 2021-02-01 08:25

    I realise this is a bit old now, but for those looking for an answer, this is what I found.

    select * from master..spt_values where type = 'O9T'
    
    0 讨论(0)
提交回复
热议问题