select @[email protected]('*')
for xml raw,type
Above statement will generate following alert:
Msg 6819, Level 16, State 3, Line 2
The FOR XML clause is not allowed in a ASSIGNMENT statement.
For example
DECLARE @xml_var XML
SET @xml_var =
(
SELECT *,
(
SELECT *
FROM Orders
WHERE Orders.CustomerID=Customers.CustomerID
FOR XML AUTO, TYPE
)
FROM Customers WHERE CustomerID='ALFKI'
FOR XML AUTO, TYPE
)
refer to : http://blogs.msdn.com/sqlprogrammability/articles/576095.aspx
DECLARE @RESULTS XML
SET @RESULTS = (SELECT * FROM Table_Name FOR XML AUTO)
SELECT @RESULTS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With