Concatenate child record fields by parent records in T-SQL?
Posted on 2011-05-02
Hello - I have to concatenate contacts names associated with given clients for use in a mail merge routine. Is there a way to do this in T-SQL (SS 2000)?
Actually, I have to create 2 formats; the first is the typical "cc" format that you would expect in the letter closing, where the contact name is followed by the contact company, indented on a 2nd line:
cc: Alex Adams
The Adams Company
The Barker Group
Carter & Associates
The second format is just the contact names, separated by commas:
Alex Adams, Bob Barker, Clyde Carter
There could be hundreds of clients, most with 1 - 3 contacts, some with a maximum of 10
I have done some simple Views, and a couple of simple scalar functions, but this makes my head hurt.
Thanks for any help.