This is a discussion on Select Query - can I use a Pivot table? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello all, I have tried this in SQL 2000 with no luck, with pivot table feature in 2005 I ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello all, I have tried this in SQL 2000 with no luck, with pivot table feature in 2005 I see some hope. Here is my problem, I have a table with n rows. data within these is simple varchar. I want to pull the data in these rows and create a table. Ex: Table1 data looks like this (actual table is much much bigger): # columnName -- ------------------- 1 Name 2 Age 3 City I want to create a table which has 'Name, Age, City...' as the columns in it. So basically I am moving a table sideways as in Excel. I can now do this using a dirty cursor that reads all the columns in the first table into a param and then I build a 'Create table' out of it and use dynamci SQL to run it. this is ugly since and it not recommended for various reasons. Question now is can I use the Pivot table to some how magically create a table out of the first table? if so please advice SQL gurus. It will be a great help for me. thanks adi |