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

求sql语句查询第2列的字段名
求sql语句查询第2列的字段名

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

select name from (
select row_number()over(order by getdate()) as id,
name from syscolumns where id=object_id('表名'))a where id=2

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

declare @table_name varchar(200)
set @table_name = 'test'--表名称
select o.name as table_name,c.name as colcumn_name,c.colorder,c.* 
from syscolumns c,sysobjects o
where c.id = o.id
and o.xtype = 'u'
and o.name = @table_name
and c.colorder = 2--只取第2个字段

------解决方案--------------------
探讨
求sql语句查询第2列的字段名