I'm not really sure how to label the task before me so I'll just describe it. Hopefully it will be something people do every day (except for me).
I need to do a query that will return records where a column is actually a record in a single table holding multiple columns.
Table A ------- Column Name Column Value ... Record GUID
The "record" would be comprised of all the columns from Table A with matching GUIDs
So the result would be
Column A, Column B, Column C
Column A Column B Column C
It sounds like a Pivot, but since the number of columns could be variable, it doesn't seem to fit into the stringent Pivot setup.
This is pretty much what the requirements are and I can't change them to something else. So while thoughtful suggestions on alternative approaches are appreciated, it is not within my power to implement them.
It is a pivot just not using the pivot statement (which I agree isn't all that usefull). Have a look at dynamic sql. I think Robvolk has an article on here about creatoing a pivot getting the column details from the system tables.
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy.