2016-05-19 98 views
-2

比方說,我有選擇逗號分隔值轉換爲單列

SELECT 1,2,3 

輸出將是

colA | colB | colC 
1 | 2 | 3 

有沒有辦法來輸出選擇1,2,3逼到一列就這樣

colA 
1 
2 
3 
+1

'select 1 union select 2 union select 3'? –

+1

[將列轉置爲使用UNPIVOT的行](http://stackoverflow.com/questions/12568779/transposing-columns-to-rows-using-unpivot) –

+1

@ shree.pat18最好是'union all'作爲一件事嚴格的正確性,但是,那。 – Blorgbeard

回答

1

在SQL Server中,你可以使用values

select * 
from (values (1), (2), (3)) v(val);