Get data from multiple columns into a single column
Posted on 2012-08-28
I am not sure why I can’t figure this out but I am at a road block and am looking for assistance on this. We are using MS SQL 2008 and I need a query that I can use with other queries and VB application with Crystal Reports.
I have a child table that sores data in 15 different fields and there can be multiple child records per parent.
ParentKey, LineNo, Field1…Field15
The LineNo records the number of lines 1…4…10…etc. in order.
What I would like to do is get the data in a different format like the below:
ParentKey LineNo FieldName Value Count
1 1 Fld01 aaa 1
1 1 Fld02 bbb 2
1 1 Fld15 ccc 15
1 2 Fld01 ddd 16
1 2 Fld15 zzz 30
Thank you for your help and suggestions.