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
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 To convert rows to columns

Author  Topic 

san2008
Starting Member

4 Posts

Posted - 2008-08-21 : 07:32:22
I have a database which contains tables with dynamic no. of columns. But since that couldn't be supported in Linq i am now using a 2 table pair, 1 for storing the column names and the other for storing the values under that column as rows. Eg;
Table1
ColumnID(int) ColumnName(VC)
01 Col1
02 Col2

Table2
ValueID(VC) Value(VC)
Col1 Value11
Col1 Value12
Col2 Value21
Col2 Value22
Col2 Value23

This arrangement solves the data storage problem but the issue arises when i have to show the data in a grid like:

Col1 Col2
Value11 Value21
Value12 Value22
Value23

I had seen a lot of articles on the same but couldn't find any of them graspable or suitable (even the ones where some pivot is used,since I am new to this).
Some guidance on this issue will be greatly appreciated.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-08-21 : 23:32:35
Did you look at pivot samples in books online?
Go to Top of Page
   

- Advertisement -