遍历数据表名、字段名、视图名甚至存储过程名

 

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 

 

posted @ 2012-08-02 14:24  Seasons1987  阅读(385)  评论(0编辑  收藏  举报