The material works on lines, the only thing it does on your SQL is to remove the starting comma from position 1. Without any thing, it will look like: a, b, c, d, but when you type in a position with an empty value, it converts it in a, b, c, d
Perhaps your question is more about what FOR XML does. In this case, FOR XML is used as a βtrickβ to combine all the lines from #tempDates into one long comma-separated line, a, b, c, d, and the material simply removes this first comma.
For xml, the line x = ', a' + ', b' + ', c' + ', d' is created, so x ends as ', a, b, c, d'
Stuff(x,1,1,'') replaces only the comma in position 1 with "c", so now x = 'a, b, c, d'
[STUFF ( character_expression , start , length , replaceWith_expression )]
Jayvee
source share