sqlserver进行查询表的结构信息内容

  • Post author:
  • Post category:其他


代码如下:

---1.查询数据库中的所有数据库名:
SELECT Name FROM Master..SysDatabases ORDER BY Name  
---2.查询某个数据库中所有的表名:
SELECT Name FROM SysObjects Where XType='U' ORDER BY Name
---3.查询表结构信息:
SELECT (case when a.colorder=1 then d.name else null end) 表名, ( d.name) 表名2,
a.colorder 字段序号,a.name 字段名,
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) 标识, 
(case when (SELECT count(*) FROM sysobjects 
WHERE (name in (SELECT name FROM sysindexes 
WHERE (id = a.id) AND (indid in 
(SELECT indid FROM sysindexkeys 
WHERE (id = a.id) AND (colid in 
(SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a



版权声明:本文为milijiangjun原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。