Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
learning_grsql
Posting Yak Master
230 Posts |
Posted - 2014-06-11 : 15:04:12
|
The both queries produce same output for me so I wonder what the difference between them are.select stuff ((select ',' + column1 from table1for xml path ('')),1,1,0) [code]select stuff((select ',' + column1 from table1for xml path (''),type).value('.', 'nvarchar(max)'),1,1,0) |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-06-11 : 15:19:17
|
quote: Originally posted by learning_grsql The both queries produce same output for me so I wonder what the difference between them are.select stuff ((select ',' + column1 from table1for xml path ('')),1,1,0) [code]select stuff((select ',' + column1 from table1for xml path (''),type).value('.', 'nvarchar(max)'),1,1,0)
If you have XML special characters in column1 (e.g. &, <, > etc.), the first query will tokenize them. Most likely that is not what you want when you are trying to concatenate. . The second query would preserve those characters literally. |
 |
|
learning_grsql
Posting Yak Master
230 Posts |
Posted - 2014-06-12 : 04:18:28
|
ok thanks |
 |
|
|
|
|
|
|