Where do I find Sql Server metadata for column datatypes?

前端 未结 3 1670
礼貌的吻别
礼貌的吻别 2021-01-11 09:52

I know that I can get access to column properties via:

select * 
from sysobjects

What I can\'t find however is information about where to g

3条回答
  •  北海茫月
    2021-01-11 10:25

    The correct way to do this is to join to user_type_id in the sys.types table:

    select object_NAME(c.object_id), c.name, t.name, c.max_length
    from sys.columns c
    INNER JOIN sys.types t
        ON t.user_type_id = c.user_type_id
    

    user_type_id is identical to system_type_id for system types - see documentation: https://msdn.microsoft.com/en-gb/library/ms188021.aspx

提交回复
热议问题