当前位置: 代码迷 >> Sql Server >> 如何用SQL语句行列交换
  详细解决方案

如何用SQL语句行列交换

热度:38   发布时间:2016-04-27 19:01:22.0
怎么用SQL语句行列交换?
有个表,就一个字段。
1
2
3
4
5

如何用SQL查询后得出如下结果
1   2   3   4   5

------解决方案--------------------
declare @temp table(c1 varchar(10))
insert @temp
select '1 ' union all
select '2 ' union all
select '3 ' union all
select '4 ' union all
select '5 '

declare @str varchar(1000)
set @str= ' '
select @[email protected]+ ' '+c1 from @temp
print @str
  相关解决方案