CREATE DATABASE xmldb
GO

USE xmldb
GO

CREATE TABLE xml_tab(
the_id INTEGER PRIMARY KEY IDENTITY,
xml_col XML)
GO

-- these work fine
INSERT INTO xml_tab VALUES('<doc1></doc1>')
INSERT INTO xml_tab VALUES(N'<doc1></doc1>')
GO

-- so does this (if first cast to varchar/nvarchar)
DECLARE @v SQL_VARIANT
SET @v = N'<someotherdoc></someotherdoc>'
INSERT INTO xml_tab VALUES(CAST(@v AS varchar(max)))
GO

-- this fails at the insert statement
DECLARE @SOMENUM FLOAT
SET @SOMENUM = 3.1416
INSERT INTO xml_tab VALUES(CAST(@SOMENUM as XML))
GO

-- ok, complete document
INSERT INTO xml_tab VALUES('<doc2></doc2>')
GO

-- ok, document fragment
-- though it's not a single well-formed document
-- (two root elements)
INSERT INTO xml_tab VALUES('<doc1></doc1><doc2></doc2>')
GO

-- ok, text element
INSERT INTO xml_tab VALUES('The Window and Shade Store')
GO

-- error, not well-formed
INSERT INTO xml_tab VALUES('The Window & Shade Store')
GO

-- error, not well-formed
INSERT INTO xml_tab VALUES('<doc1><doc2></doc1></doc2>')
GO