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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 horizontal to vertical array?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

David92595
Starting Member

USA
8 Posts

Posted - 11/29/2012 :  20:19:07  Show Profile  Reply with Quote
Hello,

Not sure if there is any basic info you need to know...I'm running SQL Server 2008 Standard.

I need to create a query that has data from multiple columns (Columns 1-6 with coresponding Date started and Date Completed data) displayed vertically, but also has the column name the preeceeding column to identify it...along with other data (Record number, status).

Record Number, Status, Column Name, Date Started, DateCompleted
1, Open, Column 1, 1/1/2012, 2/1/2012,
2, Hold, Column 2, 1/3/2012, 3/1/2012,
1, Open, Column 3, 2/5/2012, 4/6/2012,
3, Closed, Column 4, 5/10/2012, 7/25/2012,
2, Hold, Column 5, 3/9/2012, 4/1/2012,
1, open, Column 6, 10/10/2012, 12/12/2012,


Please reply with any question you may have. Sorry, I did the best I could to describe what I need, the formating wasn't helping either. I went with CSV, if it helps.

As Always, any help would be greatly apprechated.
Thank you,
David92595

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 11/29/2012 :  21:31:11  Show Profile  Reply with Quote
Can you explain with expected output?
Go to Top of Page

David92595
Starting Member

USA
8 Posts

Posted - 11/30/2012 :  12:39:56  Show Profile  Reply with Quote
By Horizontal I mean Column 1 -6 would be normal columns in a table.
I need to take a normal table

Column1,Column2,Column3,Column14,Column5,Column6, Date Started, DateCompleted
Data, Data, Data, Data, Data, Data, Data, Data,
Data, Data, Data, Data, Data, Data, Data, Data,
Data, Data, Data, Data, Data, Data, Data, Data,

With data in each column and turn it into

Column Name,Date Started, Date Completed
Column1,data, data,
Column2,data, data,
Column3,data, data,
Column4,data, data,
Column5,data, data,
Column6,data, data,

Hope this helps explain thing a bit better,
David92595
Go to Top of Page

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 11/30/2012 :  14:25:55  Show Profile  Reply with Quote
Check for UNPIVOT and you can find lots of post for it.
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.07 seconds. Powered By: Snitz Forums 2000