SQLSERVER 查看数据库 表名称、表说明、列名称等
SELECT 表名称= d.name, 表说明= isnull(f.value,''), 排序号= a.colorder, 列名称= a.name, 列说明= isnull(g.[value],''), 标识列= case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then 1 else 0 end, 主键列= case when exists(SELECT 1 FROM sysobjects where xtype='PK' and parent_obj=a.id and name in (SELECT name FROM sysindexes WHERE indid in( SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid))) then 1 else 0 end, 列类型= b.name, 字节数= a.length, 列长度= COLUMNPROPERTY(a.id,a.name,'PRECISION'), 小数位= isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0), 允许空= case when a.isnullable=1 then 1 else 0 end, 默认值= isnull(e.text,'') FROM syscolumns a LEFT JOIN systypes b on a.xusertype=b.xusertype INNER JOIN sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' LEFT JOIN syscomments e on a.cdefault=e.id LEFT JOIN sys.extended_properties g on a.id=G.major_id and a.colid=g.minor_id LEFT JOIN sys.extended_properties f on d.id=f.major_id and f.minor_id=0 ORDER BY 表名称 ASC,排序号 ASC
摘自网络。。