I have a variable called result of type Xml that contains one cell of Xml text. I cannot seem to use SELECT INTO to insert this value into another temp table.
SELECT @result
INTO dbo.xml_temp
Is there a way to achieve this?
If you want to insert the XML into an existing table, you have
VALUES INSERT INTO ... SELECT ...:Try this:
DECLARE @tbl TABLE(ID INT IDENTITY,TargetColumn XML);
DECLARE @SomeXML XML ='<root>test</root>';
INSERT INTO @tbl VALUES(@SomeXML);
INSERT INTO @tbl(TargetColumn) SELECT @SomeXML;
SELECT * FROM @tbl;
If you really want to create a new temp table, your statement is just missing an alias (How should the new table know the column's name?):
SELECT @SomeXML AS SomeName INTO #tmpTable;
SELECT * FROM #tmpTable;
SELECT @result AS XmlOutput?