SQL Server查询所有数据库,一个数据库中所有表和表的所有字段

2014-11-24 10:20:57 · 作者: · 浏览: 0
SQL Server查询所有 数据库,一个数据库中所有表和表的所有字段
查询所有的数据库
1
select [name] from [sysdatabases] order by [name]

查询一个数据库中的所有表『 [type] = 'u' 是用户表,[type] = 's'是系统表』
1
select [id], [name] from [sysobjects] where [type] = 'u'

根据上个语句的查询结果然后再查询一个表中的所有字段

1
select [name] from [syscolumns] where [id] = 1931153925