Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 make rows from comma separated values

Author  Topic 

ranjana
Starting Member

1 Post

Posted - 2012-11-27 : 13:02:02
Hi ,

I have two columns in a table that have value like

columnname(a,b,c,d)
value(1,2,3,4)

now i need output like

columnname value
a 1
b 2
c 3
d 4

please suggest need full.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-11-27 : 13:03:51
never mind, I misread your post!
Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-11-27 : 13:11:15
here we go


declare @table table( a int,b int,c int,d int)

insert into @table
values(1,2,3,4)
select *
from (select a,b,c,d
from yourTable )p
UNPIVOT (value for columnName in (a,b,c,d)
) as unpvt


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -