Readers' mail: concatenate text from multiple rows ... exceptions and limitations
Hi guys, Today I wanted to answer mr. Brian Walker who wrote me an email and pointed out a series of important notes about the concatenation of the text we talked about yesterday I thank him because what I like most is the exchange of ideas! Brian sent me a script where we see that the syntax we talked about yesterday has some limitations. Let's see them. First of all he created a table #name and filled it with some data CREATE TABLE #Names (Name varchar(20)) INSERT #Names VALUES ('X1') , ('X2') , ('X3') , ('Y1') , ('Y2') , ('Y3') , ('Z1') , ('Z2') , ('Z3') These are our data... He showed me that putting in the "order by" clause the field name it's ok! DECLARE @Names varchar(1000) SELECT @Names = ISNULL(@Names, '') + ' ' + N.Name FROM #Names AS N ORDER BY N.Name SELECT @Names SET @Names...