日期:2014-05-17  浏览次数:20573 次

怎么查询表的字段
问个菜菜的问题,怎么查询表的字段,- -

------解决方案--------------------
“表名”部分你自己写
SQL code
Select name from syscolumns Where ID=OBJECT_ID('表名')

------解决方案--------------------
SQL code
Select name from syscolumns Where id=object_id('tb'

------解决方案--------------------
SQL code

select name from syscolumns Where id=object_id('tb')

------解决方案--------------------
--获取表名
1、SELECT name FROM sys.sysobjects WHERE TYPE='U'
2、SELECT name FROM sys.tables WHERE TYPE='U'
3、SELECT name FROM sys.objects WHERE TYPE='U'
--获取表名,字段及类型
SELECT b.name tableName,a.name columnName,c.name typeName FROM sys.columns a
inner join sys.objects b
on a.object_id=b.object_id and b.TYPE='U'
inner join sys.types c
on a.user_type_id=c.user_type_id --and c.name='bit' -- 字段类型
order by a.object_id,column_id