Solved

problem in executing "sp_xml_preparedocument" stored procedure

Posted on 2006-10-24
3
620 Views
Last Modified: 2008-02-26
Hello,

I am executing this below code in sql queryanalyzer .It returns the null value.

Here is my code

 exec sp_xml_preparedocument @hDoc OUTPUT,'<Shops><Shop><col1>01000200</col1><col2>49.035792</col2><col3>-122.338480</col3><col4>ADDRESS</col4></Shop></Shops>'
Select col1,col2,col3,col4
 FROM OPENXML(@hDoc, 'Shops/shop')  
 WITH (col1 varchar(10),col2 varchar(50),col3 varchar(50),col4 varchar(50))

output
-----------------
col1   col2  col3  col4
---------------------------
null  null    null    null

But it should return the value of col1,col2,col3,col4.

Could anyone help me for this.

0
Comment
Question by:r_pat72
3 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 17800798
Try it this way:

Select      col1,
            col2,
            col3,
            col4
FROM      OPENXML(@hDoc, 'Shops/Shop') WITH (
            col1 varchar(10) 'col1',
            col2 varchar(50) 'col2',
            col3 varchar(50) 'col3',
            col4 varchar(50)'col4')
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now