Possible Duplicates:
Simulating group_concat MySQL function in MS SQL Server 2005?
Concat groups in SQL Server
I am trying to write an SQL query that will combine rows together. I need it to group together an unspecified number of rows by ID# but concatenate their addresses let's say into one cell.
Say we have
ID, Address
p1 a1
p1 a2
p1 a3
p2 a4
p2 a5
I want to get
ID, Address
p1 a1,a2,a3
p2 a4,a5
The number of addresses per ID can vary. Some IDs have 1, others can have 50.
Any help would be appreciated. Thanks in advance!