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
 Table Interchange

Author  Topic 

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-10-03 : 09:01:25
How can I change my table data from horizontal to vertical form?

Thanks

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-10-03 : 09:05:53
are you using 2005? if so take a look at UNPIVOT in books online. if that's not what you're looking for perhaps you should supply us some sample data / examples of what you're trying to do

Em
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2008-10-03 : 09:06:22
Look up the PIVOT syntax in BOL
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-10-03 : 09:06:37
I'm using 2000
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-10-03 : 09:08:46
Here's my data:

Name Question1 Question2 Question3 Question4
Mike Yes No Yes No
Michelle No Yes No Yes
Mike Yes No Yes No
Michelle Yes No Yes No

Change to this

Name Mike Michelle Mike Michelle
Question1 Yes No Yes Yes
Question2 No Yes No No
Question3 Yes No Yes Yes
Question4 No Yes No No
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 09:38:25
Do you have an ID column or unique valued column in your db?
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-10-03 : 09:41:58
Here it is again

ID Name Question1 Question2 Question3 Question4
1 Mike Yes No Yes No
2 Michelle No Yes No Yes
3 Mike Yes No Yes No
4 Michelle Yes No Yes No

Change to this

ID 1 2 3 4
Name Mike Michelle Mike Michelle
Question1 Yes No Yes Yes
Question2 No Yes No No
Question3 Yes No Yes Yes
Question4 No Yes No No
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 10:06:54
some methods here

http://www.mssqltips.com/tip.asp?tip=937
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-10-03 : 10:09:00
what do you suggest on my problem?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 10:12:20
quote:
Originally posted by BankOfficerHere

what do you suggest on my problem?


go through various methods in posted link and see what method fits your requirement best.
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-10-03 : 10:14:51
can you give me the statement to my problem? thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 10:17:56
quote:
Originally posted by BankOfficerHere

can you give me the statement to my problem? thanks


did you even had a look at any one method in posted link? Dont expect somebody to provide you a full solution. Just go through the link and at least make a try to find solution yourselves. If you get stuck up somewhere then we will help you.
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-10-03 : 10:26:46
I'm just starting and already stuck up
Go to Top of Page
   

- Advertisement -