1 SELECT 2 col.name AS 列名, 3 typ.name as 数据类型, 4 col.max_length AS 占用字节数, 5 col.precision AS 数字长度, 6 col.scale AS 小数位数, 7 col.is_nullable AS 是否允许非空, 8 col.is_identity AS 是否自增, 9 case when exists 10 ( SELECT 1 11 FROM 12 sys.indexes idx 13 join sys.index_columns idxCol 14 on (idx.object_id = idxCol.object_id) 15 WHERE 16 idx.object_id = col.object_id 17 AND idxCol.index_column_id = col.column_id 18 AND idx.is_primary_key = 1 19 ) THEN 1 ELSE 0 END AS 是否是主键, 20 isnull(prop.[value],‘-‘) AS 说明 21 FROM 22 sys.columns col 23 left join sys.types typ 24 on (col.system_type_id = typ.system_type_id) 25 left join sys.extended_properties prop 26 on (col.object_id = prop.major_id AND prop.minor_id = col.column_id) 27 WHERE 28 col.object_id = 29 (SELECT object_id FROM sys.tables WHERE name = ‘band‘)