SQL语句查询数据库所有表和所有字段的详细信息(包括表描述和字段描述),从网上搜来,自己完善了一些,添加了表的描述信息(MS_Description),在MSSMS执行通过。供参考。
SELECT
(case when a.colorder=1 then ddd.value else '' end) as "表名(中文)",--如果表名相同就返回空
(case when a.colorder=1 then d.name else '' end) as 表名,--如果表名相同就返回空
(case when a.colorder=1 then ddd.value else '' end) as 表说明,--如果表名相同就返回空
a.colorder as 字段序号,
a.name as 字段名,
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) as 是否自增标识,
(case when (SELECT count(*) FROM sysobjects--查询主键
WHERE (name in
(SELECT name FROM sysindexes
WHERE (id = a.id) AND (indid in
(SELECT indid FROM sysindexkeys