Опция для SQLServer2008 + с операторами CROSS APPLY и PIVOT
CREATE TABLE dbo.test77
(
id int IDENTITY,
colA char(1),
colB char(1),
colC char(1)
)
INSERT dbo.test77
VALUES('a','b','c'),
('d','e','f'),
('g','h','i')
SELECT [1], [2], [3], [4], [5]
FROM (
SELECT COALESCE(o.colA, o.colB, o.colC) AS Val,
'Col' + CAST(ROW_NUMBER() OVER (ORDER BY id) AS nvarchar(1)) AS ColName
FROM dbo.test77 t CROSS APPLY (
VALUES(colA, NULL, NULL),
(NULL, colB, NULL),
(NULL, NULL, colC)
) o(colA, colB, colC)
) p
PIVOT (
MAX(Val) FOR ColName IN ([Col1], [Col2], [Col3], [Col4], [Col5], [Col6], [Col7], [Col8], [Col9])
) pvt CROSS APPLY (
VALUES ([Col3], NULL, NULL, NULL, NULL),
([Col2], [Col6], NULL, NULL, NULL),
([Col1], [Col5], [Col9], NULL, NULL),
([Col4], [Col8], NULL, NULL, NULL),
([Col7], NULL, NULL, NULL, NULL)
) o([1], [2], [3], [4], [5])
Демонстрация по SQLFiddle