根据数据库表名查询该表字段名、字段类型、以及注释

SELECT  c.name AS column_name ,
        t.name AS data_type ,
        ( SELECT    value
          FROM      sys.extended_properties AS ex
          WHERE     ex.major_id = c.object_id
                    AND ex.minor_id = c.column_id
        ) AS notes
FROM    sys.columns AS c
        INNER JOIN sys.tables AS ta ON c.object_id = ta.object_id
        INNER JOIN ( SELECT name ,
                            system_type_id
                     FROM   sys.types
                     WHERE  name <> 'sysname'
                   ) AS t ON c.system_type_id = t.system_type_id
WHERE   ta.name = 'PE_Address'
ORDER BY c.column_id

 

'PE_Address' 为要查询的数据表名;

 

你可能感兴趣的:(SQL,Server,数据库)