Wednesday, March 28, 2012

Read Value from XML

This is My example :
DECLARE @.idoc int
DECLARE @.doc varchar(4000)
SET @.doc ='
<NEWDATASET>
<TABLE1>
<INTERO>1</INTERO>
</TABLE1>
</NEWDATASET> '
EXEC sp_xml_preparedocument @.idoc OUTPUT, @.doc
Select * FROM OPENXML (@.idoc, '/NEWDATASET/TABLE1',1)
WITH (INTERO int)
Not function, why?
John,
You need to identify the element in the WITH clause... also, don't forget to
remove the document reference when you're done:
DECLARE @.idoc int
DECLARE @.doc varchar(4000)
SET @.doc ='
<NEWDATASET>
<TABLE1>
<INTERO>1</INTERO>
</TABLE1>
</NEWDATASET> '
EXEC sp_xml_preparedocument @.idoc OUTPUT, @.doc
Select * FROM OPENXML (@.idoc, '/NEWDATASET/TABLE1',1)
WITH (INTERO int 'INTERO')
exec sp_xml_removedocument @.idoc
"John" <ch@.msn.com> wrote in message
news:%23id3kIfsEHA.2128@.TK2MSFTNGP11.phx.gbl...
> This is My example :
> DECLARE @.idoc int
> DECLARE @.doc varchar(4000)
> SET @.doc ='
> <NEWDATASET>
> <TABLE1>
> <INTERO>1</INTERO>
> </TABLE1>
> </NEWDATASET> '
> EXEC sp_xml_preparedocument @.idoc OUTPUT, @.doc
> Select * FROM OPENXML (@.idoc, '/NEWDATASET/TABLE1',1)
> WITH (INTERO int)
>
> Not function, why?
>

No comments:

Post a Comment