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.
| Author |
Topic |
|
dshelton
Yak Posting Veteran
73 Posts |
Posted - 2003-04-30 : 21:48:03
|
| I currently have normalised table that I need to transform in to a flat file table. I would like to do this dynamically as field names and number of fields can vary. Besides writing out a loop, I was wondering if anyone had any better or quicker ideas. This table:Key Att OrderA X 1A Y 2A Z 3Needs to become:Key Att1 Att2 Att3A X Y Z |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-04-30 : 21:55:36
|
| Look at Rob's wonderful DYNAMIC SQL CROSS TAB stored procedure, in the articles. Denormalizing data in this manner is often refered to a Cross tabbing.here's the link:http://www.sqlteam.com/item.asp?ItemID=2955Also, read all of the comments (make sure you have some time!) for variations on his techinque and other ideas.(my comment -- #60 !! -- shows a pretty short and very flexible method that lets you pivot non-numeric columns and use functions like MIN() or MAX(), and also perform multiple pivots)- JeffEdited by - jsmith8858 on 04/30/2003 21:59:10 |
 |
|
|
|
|
|