首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

怎么按序号取得某张表中的某个字段的值

2012-01-29 
如何按序号取得某张表中的某个字段的值?我要取第5个字段的值:selectfield(5)fromtableName显然是不行怎么

如何按序号取得某张表中的某个字段的值?
我要取第5个字段的值:

select   field(5)   from   tableName
显然是不行

怎么做呢?

[解决办法]
declare @a varchar(1000)

select @a= 'select '+name + ' from [TableName] ' from syscolumns b where id=object_id( '[dbo].[TableName] ') and colid=5
exec(@a)



[解决办法]
支持楼上

热点排行