查询数据的库名 查询指定数据库下的表名 查询指定数据库下的指定表的列名

查询所有数据库名
SELECT Name FROM Master..SysDatabases
查询指定数据库下的表名和视图名
select * from 数据库名..sysobjects where xtype='V'or xtype='U'
查询指定数据库下的指定表的列名
   select name from 数据库名.dbo.syscolumns where id=(select id from 数据库名.dbo.sysobjects where (xtype='U' or xtype='V' ) and name='表名')
select  * from 数据库名.information_schema.columns t left join  数据库名.[dbo].syscolumns  q on t.COLUMN_NAME = q.name and q.id=object_id('表名') where t.table_name='表名'
原文地址:https://www.cnblogs.com/skyhorseyk/p/9212464.html