do a site search on "csv" for lots of discussion about this but here is the jist:you can run this code as is to see the results:use pubsgocreate view vwBookedCateringasselect 754 [id], 'Coffee' [description] union allselect 754, 'Tea' union allselect 754, 'Water' union allselect 755, 'Coffee' union allselect 755, 'Tea' union allselect 755, 'Water' union allselect 756, 'Coffee' union allselect 756, 'Tea'go--Create a function that returns the comma seperated values for a given IDcreate function dbo.BookingsById(@id int)returns varchar(8000)asbegin declare @out varchar(8000) select @out = coalesce(@out + ', ' + [description], [description]) from vwBookedCatering where [id] = @id return @outendgo--Use the functionselect [id] ,dbo.BookingsById([id]) [Bookings]from (select distinct [id] from vwBookedCatering) agodrop function dbo.BookingsByIddrop view vwBookedCatering
Be One with the OptimizerTG