views:

20

answers:

1

I have a query like the following:

;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.

+3  A: 
DECLARE @MYXML AS XML

;WITH XMLNAMESPACES ( DEFAULT 'http://www.somewhere.com')
SELECT @MYXML = (
   SELECT ( 'SOMETHING' )
   FOR XML PATH('RootNode'), TYPE)
Remus Rusanu
I could hug you
YourMomzThaBomb