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
 Database Design and Application Architecture
 Transpose

Author  Topic 

aditis
Starting Member

1 Post

Posted - 2013-08-14 : 08:26:38
I have a table like this:
ID Q1 A1 Q2 A2
R 1 A B C D

and I want the result to be like this:

ID Q A
R1 1 A B
R2 1 C D

Please tell me the query to solve this

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-08-14 : 08:37:57
SELECT ID, Q1 AS Question, A1 Answer FROM tableName
UNION ALL
SELECT ID, Q2, A2 FROM tableName

--
Chandu
Go to Top of Page
   

- Advertisement -