Solved

Stored procedure  - OPENXML

Posted on 2003-12-04
1
551 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

932 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