here is my xml which i want to show as tabular form
DECLARE @xml XML
SET @xml = '<root>
<row>one</row>
<row>two</row>
<row>three</row>
</root>'
SELECT
x.y.value('(row/text())[1]', 'varchar(5)')
FROM @xml.nodes('root') x(y)
it is displaying only first rows. i want to display data like
Mycolumn
-----------
one
two
three
please guide me what i need to change in my sql. thanks
i could not issue select into with xquery like the below way
DECLARE @xml XML
SET @xml = '<root>
<row>one</row>
<row>two</row>
<row>three</row>
</root>'
SELECT *
INTO #Fields
FROM (SELECT
x.y.value('text()[1]', 'varchar(5)') as fields11
FROM @xml.nodes('root/row') x(y))
SELECT * FROM #Fields
DROP TABLE #Fields
but i could use insert into with xuqery like below way
DECLARE @xml XML
SET @xml = '<root>
<row>one</row>
<row>two</row>
<row>three</row>
</root>'
CREATE TABLE #Fields(Field varchar(MAX))
INSERT INTO #Fields
SELECT
x.y.value('text()[1]', 'varchar(5)')
FROM @xml.nodes('root/row') x(y)
SELECT * FROM #Fields
DROP TABLE #Fields
so anyone can help me to construct select into with xquery. thanks
NOW Select into works with XQUERY
DECLARE @xml XML
SET @xml = '<root>
<row>one</row>
<row>two</row>
<row>three</row>
</root>'
SELECT x.y.value('text()[1]', 'varchar(5)') Mycolumn into #Fields
FROM @xml.nodes('root/row') x(y)
select * from #Fields
drop table #Fields