Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 OPENXML

Author  Topic 

mrkapoor
Starting Member

1 Post

Posted - 2010-06-04 : 15:13:24
I am trying to work with OPENXML and extract data, but am getting 2 NUll values from the example below. Please help

DECLARE @list xml,

@xmlOutput int

DECLARE @table table
(
CODE int NULL
)

SET @list = '<xmlversion="1.0"><CODES><CODE>1</CODE><CODE>2</CODE></CODES>'

EXEC sp_xml_preparedocument @xmlOutput OUTPUT, @list

INSERT INTO @table

SELECT
*
FROM OPENXML(@xmlOutput, '//CODES/CODE', 2) WITH (CODE int)

SELECT * FROM @table

EXEC sp_xml_removedocument @xmlOutput


RK

Sachin.Nand

2937 Posts

Posted - 2010-06-04 : 15:44:16
Try This
Select x.i.value('.','varchar(10)') from @list.nodes('/CODES/CODE')x(i)

Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page
   

- Advertisement -