I want to “concatenate” all the “Text”-rows into one single row and get one row as a result. Is this even possible? I use MSSQL Server 2005.

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use FOR XML PATH:
Another option – use string concatenation:
Please note that the latter one isn’t guaranteed to work, afaik, officially the behaviour of “@s = @s + …” for multi-row resultset is undefined.
MAXDOP 1hint is used here to prevent the optimizer from creating a parralel execution plan, as this will yield an incorrect result for sure.