Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

openxml only returns one row

Posted on 2007-10-05
3
Medium Priority
?
837 Views
Last Modified: 2008-01-09
On SQL Server 2000 the following only returns the first row.  Why? and how can I fix it?

declare @xml varchar(8000), @hDoc int

set @xml =
'<root>
      <RowId>DATA HERE</RowId>
      <RowId>MORE DATA HERE</RowId>
</root>'

exec master.dbo.sp_xml_preparedocument @hdoc out, @xml

select RowId
from openxml(@hdoc, '/root', 2)
with (RowId char(25))

exec master.dbo.sp_xml_removedocument @hdoc
0
Comment
Question by:xmstr
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 400 total points
ID: 20022938
Hello xmstr,

select RowId
from openxml(@hdoc, '/root/RowId')
with (RowId char(25) '.')



Aneesh R
0
 
LVL 3

Author Comment

by:xmstr
ID: 20023006
It works, Thank you aneeshattingal!

Can you tell me what the '.' does in the with line?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20023840
(@hdoc, '/root/RowId', 2)  --- means you are at this node
and what you really need was, everything inside this tag, and '.' will take everything
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question