Solved

Stored procedure  - OPENXML

Posted on 2003-12-04
1
548 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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

772 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