January 22, 2003 05:22 PM

OpenXML's @mp:id Meta-property

Inserting hierarchical XML data into IDENTITY columns
Rating: (0)
SQL Server Magazine
InstantDoc ID #27473
You routinely encounter hierarchies in organization charts, parts lists, invoices that have line items, and the file system on your computer. The advent of XML provided a convenient way to represent these hierarchies by nesting entities (XML elements) inside one another. This approach is convenient when you're designing applications that present data hierarchically. But inserting hierarchically formatted XML data into your SQL Server database can pose a challenge, especially when the tables in y...

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

P.S. andy.hart@claybrook.co.uk comment is absolultely relevant... without the steps he mentioned, the procedure is useless in real world!

Miroslav2/19/2008 5:34:09 PM


Brilliant!

Miroslav2/19/2008 4:48:13 PM


I have a couple of issues with this approach:
Concurrency & Data Integrity: executing the stored procedure simultaneously by mupltiple users (with different xml documents) would give unexpected results due to the clashing of ImportIDs between the different sessions.
This could be avoided by wrapping the work done by the stored procedure in one transaction so that other sessions would only see their own data when inserting the Line Item rows. The stored procedure would also need to then set all the ImportIDs to NULL in the Order table so that they will not later clash with other inserts.

andy.hart@claybrook.co.uk 5/14/2007 8:25:50 AM


example of declare in an application

HOW TO: Perform Bulk Updates and Inserts Using OpenXML with .NET Providers in Visual C# .NET

http://support.microsoft.com/default.aspx?scid=kb;en-us;315968



Anonymous User 6/5/2005 10:27:49 AM


The OpenXML statement specifies the reference to the document in the variable @doc and specifies the XPath query //Order as the row selector.

Must declare the variable '@iDoc'.

Anonymous User 6/5/2005 9:52:32 AM


You must log on before posting a comment.

Are you a new visitor? Register Here
GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS