Why not?You have to separate the "prepare sample" section with "show expected output".The first section is just for preparing some sample data because we have no access to your environment, right?What you need is the second section only, the "show expected output".Just replace @Sample table name with the table name used in your environment.You didn't tell us the name of the table, so yo justhave to do something for yourself.-- Show the expected outputSELECT DISTINCT s1.ID, STUFF((SELECT DISTINCT TOP 100 PERCENT ',' + s2.CODE FROM @Sample AS s2 WHERE s2.ID = s1.ID ORDER BY ',' + s2.CODE FOR XML PATH('')), 1, 1, '') AS CODESFROM @Sample AS s1ORDER BY s1.IDSELECT DISTINCT s1.ID, STUFF((SELECT TOP 100 PERCENT ',' + s2.CODE FROM @Sample AS s2 WHERE s2.ID = s1.ID ORDER BY ',' + s2.CODE FOR XML PATH('')), 1, 1, '') AS CODESFROM @Sample AS s1ORDER BY s1.IDSELECT DISTINCT s1.ID, STUFF((SELECT ',' + s2.CODE FROM @Sample AS s2 WHERE s2.ID = s1.ID FOR XML PATH('')), 1, 1, '') AS CODESFROM @Sample AS s1ORDER BY s1.ID
E 12°55'05.25"N 56°04'39.16"