sql server2008怎么实现查询某个数据库中所有的表名,以及相应的表字段结构。
发布网友
发布时间:2022-04-08 01:22
我来回答
共1个回答
热心网友
时间:2022-04-08 02:51
你是要写代码生成器么?
--这是查表的数量
Select [name] from sysObjects Where xtype='U'and [name]<>'dtproperties' Order By [name]
--得到数据库中所有用户视图
Select [name] From sysObjects Where xtype='V' And [name]<>'syssegments' And [name]<>'sysconstraints' Order By [name]
--获得指定表中所有的列
Select
c.name As ColumnName,
t.name As TypeName
From syscolumns c, systypes t, sysobjects o
Where c.xtype = t.xusertype
And c.id = o.id
And o.name = 'Book'
Order By c.colorder