遍历数据表名、字段名、视图名甚至存储过程名
1、查询数据库中所有的用户表:
select [name] from sysobjects where xtype='u' select * from information_schema.tables
2、查询某表[tableName]中所有的字段名称:
select [name] from syscolumns where id = object_id('[tableName]') select * from information_schema.columns where TABLE_NAME='[tableName]'
3、查询所有视图信息:
select [name] from sysobjects where xtype='v' select * from information_schema.views