Transpose Select query result | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Transpose Select query result

How can I traspose result in SQL Say, I got result from Select query like
Param1 Value1
Param2 Value2
Param3 Value3
Param1 Value4
Param2 Value5
I want to see it like
Param1Param2Param3Param1Param2
Value1Value2Value3Value4Value5 Please help Thx Harsh
That is called a crosstab query (or report). IMHO it is best done at the client, not the server.
However google on cross tab + T SQL and you’ll receive numerous returns. –Frank
http://www.insidesql.de

or you could wait for sql2005… <img src=’/community/emoticons/emotion-5.gif’ alt=’;-)’ /><br /><br />Cheers<br />Twan
Thx Guys I was able to do it using Cusrsors…may not be the most optimum solution, but serves my purpose. Harsh
Hi Harsh,
I am not sure about it but the following solution might help you. Testing
IDValue
————–
1A
2B
3C
4D
5E
DECLARE @strID VARCHAR(100)
DECLARE @strValue VARCHAR(100) SELECT @strID = ”, @strValue = ” SELECT @strID = @strID + CONVERT(VARCHAR, ID), @strValue = @strValue + Value FROM Testing PRINT @strID
PRINT @strValue Regards,
amitm79
]]>