See below DDL:
create table
and SQL below:
select * from #Test for xml path('')
which returns:
<id>1</id> <Name>Ian</Name> <id>1</id> <Name>Mark</Name> <id>2</id> <Name>James</Name> <id>3</id> <Name>Karen</Name> <id>3</id> <Name>Suzie</Name>
This is what I would expect. Now see SQL below:
SELECT distinct ID, STUFF( (select ','+ NAME from
which returns:
1 Ian,Mark 2 James 3 Karen,Suzie
This is what I want to return. However, where are the XML elements left?
sql sql-server
w0051977
source share