此查询工作正常
SELECT 1 AS TAG, NULL AS parent, 1 [dog!1]
UNION (SELECT 1,NULL, 3)
FOR XML EXPLICIT, ROOT('dogs')
我想将它分配给一个变量。没有工会,这可以正常工作:
DECLARE @x xml
SET @x = ((
(SELECT 1 AS TAG, NULL AS parent, 1 [dog!1]
FOR XML EXPLICIT, ROOT('dogs'))
))
一旦我介绍了工会,它就不起作用了:
DECLARE @x xml
SET @x = ((
(SELECT 1 AS TAG, NULL AS parent, 1 [dog!1]
UNION (SELECT 1,NULL, 3)
FOR XML EXPLICIT, ROOT('dogs'))
))
尝试了各种各样的事情。我错过了什么