I don’t think I can use STUFF – XML PATH to do this, doesn’t seem to work. I have an average of five rows I need to concatenate into a custom column; I’m an SQL Newbie and cannot figure out how to go about this. Is there a way to refer to row numbers, then grab the row values and use CONCAT to put them in a single string? This seems like it should be easy, but I am totally stumped.
Depending on which database+version you’re using, there’s several options, but Stack Overflow is probably a better forum for general SQL questions that isn’t related to Metabase:
FOR XML is horrid to use. Depending upon your version of MS SQL, you can use COALESCE or STRING_AGG.
This is helpful: