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

怎样查询表的字段名阿。急
谁帮帮我啊

------解决方案--------------------
select name from syscolumns where id=object_id( '表名 ')
------解决方案--------------------
select name from syscolumns where id=object_id( '表名 ')
------解决方案--------------------
sp_columns TBN
------解决方案--------------------
CREATE view TableColumn as
select t3.name as TableName, t1.name as ColumnName, t2.name as DataType,
t1.length as DataLength,t4.text as cdedefault,t1.isnullable, '( '+cast(t1.xprec as char(2))+ ', '+cast(t1.xscale as char(2))+ ') ' as jingdu from syscolumns t1 left join syscomments t4 on t4.id=t1.cdefault inner join sysobjects t3 on t1.id=t3.id
inner join systypes t2 on t1.xusertype=t2.xusertype
where t3.xtype= 'U '

给你一个视图,可以查询当前有那些用户表 !每个表里字段类型,长度,默认值!
------解决方案--------------------
sp_help '表名 '
------解决方案--------------------
sp_mshelpcolumns table_name
------解决方案--------------------
sp_help tablename
------解决方案--------------------
select column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME= '表名 '
------解决方案--------------------
有点难度哦