开发者

Can't set output of 'WITH XMLNAMESPACES...FOR XML PATH' to a variable?

开发者 https://www.devze.com 2023-01-07 01:13 出处:网络
I have a query like the following: 开发者_JS百科 ;WITH XMLNAMESPACES ( DEFAULT \'http://www.somewhere.com\')

I have a query like the following:

开发者_JS百科
;WITH XMLNAMESPACES ( DEFAULT 'http://www.somewhere.com')
SELECT ( 'SOMETHING' )
FOR XML PATH('RootNode'), TYPE

Running this works fine. However, I run into troubles when I try to set the XML output to a variable like this:

DECLARE @MYXML AS XML

SELECT @MYXML = (
;WITH XMLNAMESPACES ( DEFAULT 'http://www.somewhere.com')
SELECT ( 'SOMETHING' )
FOR XML PATH('RootNode'), TYPE
)

This just give me a syntax error :-( Any ideas on how to accomplish this would be greatly appreciated.


DECLARE @MYXML AS XML

;WITH XMLNAMESPACES ( DEFAULT 'http://www.somewhere.com')
SELECT @MYXML = (
   SELECT ( 'SOMETHING' )
   FOR XML PATH('RootNode'), TYPE)
0

精彩评论

暂无评论...
验证码 换一张
取 消