查询数据库、表名称、表字段

 1 查询数据库名:
 2 use master ;select * from sysdatabases where dbid>4
 3 查询表名:
 4 SELECT * FROM SysObjects Where XType='U' ORDER BY Name 
 5 查询表中字段、长度、类型
 6 select b.name as 表名,a.name as 字段名,c.name as 数据类型,a.length as 长度
 7 from syscolumns a
 8 inner join sysobjects b on a.id=b.id
 9 inner join systypes c on a.xtype=c.xtype
10 WHERE a.id=OBJECT_ID(N'[表名称]') ORDER BY colid

 

posted @ 2013-09-13 13:43  xyzhuzhou  阅读(335)  评论(0编辑  收藏  举报