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

怎么用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 @str=@str+ ' '+c1 from @temp
print @str