>Thank you! Had to tweak it a little to get it to work with my tables but it works great. I'm still pawing through it to understand the pivot bit though.....
>As a final twist: the data I really want to put into the new table won't be the Id field but another (varbinary) field from the source table. I haven't yet worked out whether the above can be modified to do that ?
I don't see why not? If you will get stuck, you can post a closer sample of what you need - I can write a dynamic PIVOT for you.
If it's not broken, fix it until it is.
My Blog