I am trying to convert columns into rows using cursors. I know people say cursors are the right thing to do. I know we can use pivot to achieve this. But the problem is that client needs it as cursors with a for loop. Not really sure as to why they need it that way but looks like its easier for them to understand the code.
Table A
ID FieldA FieldB FieldC
1 abc 123 xyz
This needs to be converted to
ID Field0
1 abc
1 123
1 xyz
Any pointers on how to achieve it could be helpful
Thanks
Prady
UNPIVOTyou would need rather thanPIVOTand I cannot see how cursor code would be anything but less simple. The basic code you need isSELECT ID,Field0 FROM Table1 UNPIVOT(Field0 FOR FieldName IN (FieldA,FieldB,FieldC)) U