Understanding SQLServer STUFF Functions

SQLServer CAST - Convert data types to commas for partitioning. Understanding the STUFF function - The first parameter is the string FOR XML PATH (''), which must be used. The second parameter is a negative or zero empty string, which specifies the starting position for deletion or insertion. The third parameter - specifies the length of deletion, where 0 represents the string to be replaced after the previous length insertion.

-- SQLServer   CAST --convert data types   commas indicate division.      STUFF function understanding - the first one is strings FOR XML PATH('')must be used. the second parameter is a negative number or an empty string of 0, specifying the starting position for deletion or insertion. the third parameter - specifies the length of deletion, with 0 indicating insertion at the previous length and the string to be replaced                 
SELECT STUFF((SELECT  CAST(news_fenlei as VARCHAR(5)) + ',' from news WHERE isDel = 0 GROUP BY news_fenlei FOR XML PATH('')), 1, 0, '') as ids

The third parameter will change from one digit to 2.