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.
Author |
Topic |
dsthompson
Starting Member
2 Posts |
Posted - 2012-12-05 : 11:35:02
|
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.So...Table A-------Column NameColumn Value...Record GUIDThe "record" would be comprised of all the columns from Table A with matching GUIDsSo the result would beColumn A, Column B, Column CNotColumn AColumn BColumn CIt 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. Thanks, |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-12-05 : 11:43:33
|
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. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
dsthompson
Starting Member
2 Posts |
Posted - 2012-12-10 : 15:32:06
|
Thanks guys. You were very helpful. |
|
|
|
|
|