-2

There are bulk of sites providing information on STUFF AND FOR XML PATH but I want to know the actual use and where it can be implemented.

Please guide

SELECT DISTINCT 
    sno,
    STUFF ((SELECT ','+Scity
            FROM @abcdef T1
            WHERE T1.sno = T2.sno
            FOR XML PATH('')), 1, 1, '') 
FROM
    @abcdef T2

Now in the example above please tell me what are those quotes and 1,1 used for.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

In short, this is an idiomatic way of producing a CSV in T-SQL. If you're on a version of SQL Server that supports STRING_AGG() (SQL 2017+ iirc), then use that.

Ben Thul
  • 31,080
  • 4
  • 45
  • 68