Thanks
However I've had bad experiences with the table variable type in SQL 2000 because the optimizer is not very good at using them. In this instance I think I'll have to go down this route.
What I can't see from looking in the BOL or in books on SQL like Itzik Ben-Gans on Advanced t-SQL is any mention that what I tried to do will not work.
Anyway I'll try this out later on.
Thanks all
Simon