开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜