SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 make rows from comma separated values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ranjana
Starting Member

1 Posts

Posted - 11/27/2012 :  13:02:02  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
2869 Posts

Posted - 11/27/2012 :  13:03:51  Show Profile  Reply with Quote
never mind, I misread your post!
Jim

Everyday I learn something that somebody else already knew

Edited by - jimf on 11/27/2012 13:05:06
Go to Top of Page

jimf
Flowing Fount of Yak Knowledge

USA
2869 Posts

Posted - 11/27/2012 :  13:11:15  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000