Friday 18 May 2007

OPENXML - Data Retrieval

Simple OPENXML example to read data from wddxPacket

Note : I have escaped the single quote (') character by replacing it with 2 single quotes ('') to make this work!

DECLARE @xmlstring VARCHAR(MAX)
DECLARE @idoc int
DECLARE @doc xml

SET @xmlstring ='
    
a string -12.456 1998-06-12T04:32:12 10 second element a string -12.456
' SET @doc = CONVERT(XML,@xmlstring) EXEC sp_xml_preparedocument @idoc OUTPUT, @doc SELECT * FROM OPENXML (@idoc, 'wddxPacket/data/struct', 1)

No comments: