I'm not a sql expert, but what you want to investigate the following t-sql commands:
COALESCE<br />
<br />
PIVOT
The PIVOT command will arrange the data the way you want it, and the COALESCE command will help you put the resulting dataset into a comma-delimited string.
Google is your friend.