日期:2014-05-18  浏览次数:20442 次

如何访问数据库,得到所有的表名?
如题,有没有一个方法,可以连接数据库后,自动搜索到数据库里的每个表,返回表名?

得到表的列名可以通过   SqlDataReader.GetName(i)   得到,得到表名,应该也有类似的方法吧,有没有高人可以指点一下?谢谢

------解决方案--------------------
select name from sysobjects where xtype = 'U ' --所有用户表
------解决方案--------------------
select a.name as '表名 ',isnull(b.value, ' ') as '表注释 '
from sysobjects a left join sysproperties b
on a.id = b.id
where a.xtype = 'U '