I have an OpenXML query:
DECLARE @.hDoc int
EXEC sp_xml_preparedocument @.hDoc output,
'<query>
<games>
<gameid>20200542</gameid>
<gameid>20200180</gameid>
<gameid>20200169</gameid>
</games>
</query>
'
SELECT * FROM OPENXML(@.hdoc, '/query/games/gameid', 2)
WITH (gameid varchar(80) '../gameid')
EXEC sp_xml_removedocument @.hDoc
It returns 3 records but repeats gamid 20200542 three times.
What I want is 3 records one with each GameId. What am I doing wrong?
Try this instead:
DECLARE @.hDoc int
EXEC sp_xml_preparedocument @.hDoc output,
'<query>
<games>
<gameid>20200542</gameid>
<gameid>20200180</gameid>
<gameid>20200169</gameid>
</games>
</query>
'
SELECT * FROM OPENXML(@.hdoc, '/query/games/gameid', 2)
WITH (gameid varchar(80) '.')
EXEC sp_xml_removedocument @.hDoc
"Joe LeBaron" <Joe@.Spam.com> wrote in message
news:eD4vjeAnEHA.2948@.TK2MSFTNGP11.phx.gbl...
> I have an OpenXML query:
> DECLARE @.hDoc int
> EXEC sp_xml_preparedocument @.hDoc output,
> '<query>
> <games>
> <gameid>20200542</gameid>
> <gameid>20200180</gameid>
> <gameid>20200169</gameid>
> </games>
> </query>
> '
> SELECT * FROM OPENXML(@.hdoc, '/query/games/gameid', 2)
> WITH (gameid varchar(80) '../gameid')
> EXEC sp_xml_removedocument @.hDoc
> It returns 3 records but repeats gamid 20200542 three times.
> What I want is 3 records one with each GameId. What am I doing wrong?
>
|||Thanks... I was trying every combination of /'s and .'s. Makes perfect
sense (now).
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:%23VNHXiAnEHA.3712@.TK2MSFTNGP15.phx.gbl...
> Try this instead:
> DECLARE @.hDoc int
> EXEC sp_xml_preparedocument @.hDoc output,
> '<query>
> <games>
> <gameid>20200542</gameid>
> <gameid>20200180</gameid>
> <gameid>20200169</gameid>
> </games>
> </query>
> '
> SELECT * FROM OPENXML(@.hdoc, '/query/games/gameid', 2)
> WITH (gameid varchar(80) '.')
> EXEC sp_xml_removedocument @.hDoc
>
>
> "Joe LeBaron" <Joe@.Spam.com> wrote in message
> news:eD4vjeAnEHA.2948@.TK2MSFTNGP11.phx.gbl...
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment