IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Result]') AND type in (N'U'))
DROP TABLE [dbo].[Result]
GO
CREATE TABLE [dbo].[Result](
[RN] [int] NULL,
[1] [int] NULL,
[2] [int] NULL,
[3] [int] NULL,
[4] [int] NULL,
[5] [int] NULL
) ON [PRIMARY]
GO
insert into Result
select 1,11,12,13,14,15
union all
select 2,21,22,23,24,25
union all
select 3,31,32,33,34,35
union all
select 4,41,42,43,44,45
union all
select 5,51,52,53,54,55
select * from Result
;WITH Preresult AS
(SELECT RN AS Row,
Col,
Val
FROM Result
UNPIVOT (Val FOR Col IN ([1],[2],[3],[4],[5])) unpvt
)
--select * from Preresult
--Transform array into matrix
SELECT
Col as Row,
[1],
[2],
[3],
[4],
[5]
FROM
(SELECT Row, Col, Val FROM Preresult) t1
PIVOT
(MAX(Val)
FOR Row IN ([1],[2],[3],[4],[5])
) AS pvt
ORDER BY Row;-->replace Col for column sorting
Source: http://www.devx.com/dbzone/Article/40223/1763?supportItem=5