USE pubs
GO

-- declare a variable of type XML
DECLARE @x XML
-- now, write to it
SET @x = ( SELECT * FROM authors FOR XML AUTO, TYPE )

-- create a table
CREATE TABLE xml_tab(id INT IDENTITY PRIMARY KEY, xml_col XML)
GO
-- populate it with a FOR XML query
DECLARE @x XML
SET @x = ( SELECT * FROM authors FOR XML AUTO, TYPE )
INSERT INTO xml_tab VALUES (@x)


DECLARE @x NVARCHAR(max)
-- it is implement NOT to use TYPE qualifier here
-- or else a conversion will be required
SET @x = (SELECT * FROM pubs.dbo.authors FOR XML RAW)

