First row from a table into Single Column - Sql Query
Please look the below table,
RowID Name Age
1 Karhik 26
I want result in开发者_运维知识库 below format
Column1
1
Karthik
26
DECLARE @Table table( RowID int, Name varchar(10), Age int )
insert into @table
select 1,'Karhik',26
--Show original row
select * from @table
--Unpivot Row
select Value
from
(select cast(rowid as varchar(10)) as rowid, name, cast(age as varchar(10) )as age from @table) as x
UNPIVOT
(Value FOR [Column] IN
(rowid, name, age)
)AS unpvt
精彩评论