Msg 1086 Level 15 State 1 Line 20 The FOR XML clause is not valid in views, built-in functions, views, and subqueries when they contain a dial statement. To get around, wrap the SELECT containing the set statement using the view syntax and apply FOR XML on top of it.
I get this error when I run it:
SELECT STUFF(( SELECT 1 UNION ALL SELECT 2 FOR XML PATH('') ),1,0,'') [COLUMN]
works fine when I run this (without ALL ALL)
SELECT STUFF(( SELECT 1 FOR XML PATH('') ),1,0,'') [COLUMN]
Any suggestions why UNION ALL is not working or how to make it work inside STUFF() ?
Control freak
source share