sql server - OPENXML T-SQL not working as expected -


i'm writing stored procedure takes xml, part parses xml isn't working quite right. here's sproc:

create procedure [dbo].[sprocname]     @xml text  declare @xmlhandle int  declare @table table (     id int )  -- process xml use exec sp_xml_preparedocument @xmlhandle output, @xml  insert @table  select      id  openxml(@xmlhandle, 'ids', 2)   (     id int )  select * @table  exec sp_xml_removedocument @xmlhandle 

and calling code , result:

openxml issue

i can't seem figure out problem is. expecting 1 , 2 in temporary table, can see, have 1. now, call upon power of stackoverflow. bless me wisdom!!!

if ever possible, avoid openxml stuff - it's old, it's creaky, gobbles memory...

use built-in native xquery support in sql server 2005 , - that, can easily:

declare @table table (id int)  declare @input xml = '<ids><id>1</id><id>2</id></ids>'  insert @table(id)     select         idnode.value('(.)[1]', 'int')             @input.nodes('/ids/id') idtbl(idnode)  select * @table 

that gives 1, 2 output @table. no need call sp_xml_preparedocument , sp_xml_removedocument - run it!


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

What is the difference between data design and data model(ERD) -

ios - Can NSManagedObject conform to NSCoding -