-- 获取所有数据库名
select name from master..sysdatabases where name = 'Fly'
-- 获取所有表名
select name from Fly..sysobjects where xtype='U' order by name
--获取字段名
SELECT COLUMN_NAME,DATA_TYPE FROM Fly.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME= 'A'
--所有触发器
select name from sysobjects where xtype='TR'
--所有存储过程
select name from sysobjects where xtype='P'
--所有视图
select name from sysobjects where xtype='V'
--所有表
select name from sysobjects where xtype='U'
DECLARE
@DataBaseName nvarchar(100)
,@TableName nvarchar(100)
,@exec_Sql varchar(100)
set @DataBaseName = 'Fly'
set @TableName = 'A'
set @exec_Sql = 'SELECT COLUMN_NAME,DATA_TYPE FROM '
+ @DataBaseName
+ '.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME= '
+ '''' + @TableName +''''
exec(@exec_Sql)
本文标题:获取所有数据库名、表名、字段名
网站地址:
http://chengdu.cdxwcx.cn/article/gdeiis.html