I need to set a variable @XMLOutput
to the value of the subquery in XMLformat.
The subquery works fine on its own, but when the whole query is run i get the error:
Incorrect syntax near XML.
SELECT @XMLOutput = (SELECT loc
FROM ghhsitemap url
FOR XML AUTO, Elements)
A second problem: when specifying @XMLOutput
as a variable and set its data type to xml
it says it is not a valid data type.
How can this be resolved?