I need to select all guid node in the xml. but the code below only select the first one of them. how to do it?
DECLARE @doc XML
SET @doc =
'<ArrayOfGuid xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<guid>96eecbe2-d645-465d-8232-c7f21e3c6bf8</guid>
<guid>38985702-0c0b-4e9c-bccb-af84ba4dd7ff</guid>
<guid>67852205-092e-4db8-b31e-6f5d457db294</guid>
<guid>92cf9106-445f-4b01-8259-613596b8a2a7</guid>
</ArrayOfGuid>'
DECLARE @docHandle INT
EXEC sp_xml_preparedocument @docHandle OUTPUT,
@doc
SELECT [guid]
FROM OPENXML(@docHandle, '/ArrayOfGuid', 2)
WITH
([guid] UNIQUEIDENTIFIER)
the result is just one row: 96EECBE2-D645-465D-8232-C7F21E3C6BF8
I need all 4 rows.
There are probably better ways to do this, but here’s one of them: