Solved

Script to convert rows into column or vice-versa

Posted on 2004-09-08
2
8,698 Views
Last Modified: 2010-05-18
I need command or script to convert rows into columns or vice-versa in MS SQL 2000. Any one has ideas or commands?
0
Comment
Question by:rsrsm
2 Comments
 
LVL 26

Expert Comment

by:Hilaire
Comment Utility
Should it be a new table or just a query to make a pivot table ?
Please post sample data, current shape + expected results.

With the information you have given so far, the best I can come with is
- issue a select * in QA
- copy output to an excel file
- use Excel rotate functionality
- change column names at will
- import xl file into a new table using DTS
0
 
LVL 5

Accepted Solution

by:
g0rath earned 250 total points
Comment Utility
Here is a pivot table stored procedure that I've used and works fairly well.
http://www.sqlteam.com/item.asp?ItemID=2955

Lately I've hand coded these by hand to insure I know what they are doing.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now