Solved

Stored procedure  - OPENXML

Posted on 2003-12-04
1
553 Views
Last Modified: 2010-08-05
Hi,

how can I select an attribute using OPENXML and put it into the value of a stored procedure variable?

cheers,

henrik
0
Comment
Question by:henrikatwork
1 Comment
 
LVL 5

Accepted Solution

by:
xnmb earned 500 total points
ID: 9887829
you can do so just like any inline variable assignment in selecct queries. Sample:

declare       @ID int,
      @DOc int,
      @XML varchar(1024)

                 set @XML='<ROOT>
                  <Node>
                        <ID>1</ID>
                  </Node>
            </ROOT>'

      exec sp_xml_preparedocument @Doc output, @XML

      select @ID=ID
      from openxml(@Doc,'/ROOT/Node',2)
      with (ID int)

      select @ID as ID

      exec sp_xml_removedocument @Doc
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

773 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