views:

190

answers:

1

Hi,

I am trying to do some complex pivot query... and I need to do a select in the IN Clause...

Example of the Pivot

Looking at the Example in the above link, you can see they use the employee ids explicitly in their pivot. I would like to be able to do select instead of specifying the employee ids.

The only way I can think of doing it now, is by creating my pivot query in a string and using manipulation in a Stored Prodcedure to build the employee ids into a string, insert that into my PIVOT clause, and execute the resulting SQL....

Anyone think of a better way to do this?

+1  A: 

You pretty much have to use dynamic SQL when construction pivot queries when the pivot column contents cannot be hard coded.

Thanks rbobby, I had thought this might be the case, I was just wondering if there was some kind of funky array data type I could use... but I guess not
Mark Ellul