Thanks for the replies. In answer to "why I need to do this?" My finance people need to invoice each customer and attach the detail to each of the invoices.
I'm not new to SQL but still finding my way. I think a stored procedure or table valued function will work equally well I'm just not sure about the code syntax.
Can anyone recommend a good SQL book? I have SQL Server 2008 for Dummies but it's not helping me much. I need something that's less about the design and management of databases and more about manipulating data, complex querying and reporting.