Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQLXMLBULKLOAD question: Does it INSERT only, or can it UP..

 
   Database Help (Home) -> XML RSS
Next:  Install problem  
Author Message
Sabrina Veksler

External


Since: Nov 03, 2008
Posts: 1



(Msg. 1) Posted: Mon Nov 03, 2008 9:57 am
Post subject: SQLXMLBULKLOAD question: Does it INSERT only, or can it UPDATE as well?
Archived from groups: microsoft>public>sqlserver>xml (more info?)

[Using assembly Interop.SQLXMLBULKLOADLib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=null]

Hello all,

A piece of software that was built for us by a 3rd party uses
SQLXMLBULKLOADLib to import records from an XML feed into our database. The
XML feed includes previously-imported records that may or may not have
changed, as well as new records. When we run the bulkload utility, it
inserts duplicate records for those previously-imported, so to avoid this,
we have resorted to emptying out each table prior to running the bulkload
utility. This is not desirable because the tables often contain records that
were added through another source, such as the web interface.

I wonder if there isn't a way to accomplish the bulkload without dumping the
contents first? Each record contains a unique field that can be used as a
primary key, however, the original developer did not specify the field as a
primary key in the table. If I set the field as a primary key in the table,
can the bulkload be configured so that when it processes the nodes in the
XML file, it updates existing records and only inserts when the record
doesn't already exist in the table?

Because I didn't originally write this code, I would prefer to keep my
revisions to a minimum, unless there is a much better way of importing the
XML feed into our database that I can write fairly quickly.

Also, I was wondering if there is a utility to quickly generate XSD schemas
to use in the bulkload from the actual tables in SQL Server. I'd like to
modify our schemas to include the relationships and keys that I've set up
using the Management Console, but would much rather avoid doing it manually.
Please advise.

Thank you!
-Sabrina

 >> Stay informed about: SQLXMLBULKLOAD question: Does it INSERT only, or can it UP.. 
Back to top
Login to vote
Charles Wang [MSFT]

External


Since: Apr 18, 2008
Posts: 268



(Msg. 2) Posted: Tue Nov 04, 2008 2:25 am
Post subject: RE: SQLXMLBULKLOAD question: Does it INSERT only, or can it UPDATE as well? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Sabrina,
Thank you for using Microsoft MSDN Managed Newsgroup.

From your description, I understand that you used SQLXMLBULKLOADLib in a third party software to import data from an XML source into
your database. However you do not want to first delete the data from the table and then bulk insert the data into to the table. You would
like to have it update existing records and only insert new records which do not exist in the table. Also you would like to modify your
schemas to include the relationships and keys in an easy way but not manually.
If I have misunderstood, please let me know.

Unfortunately what you were asking for are product limitations in SQLXMLBULKLOADLib. SQLXMLBULKLOADLib does not provide update
data function. If you want this function, you need to code to implement it by yourself. If there are large of data, checking for update may
also lead to performance issue. Generally the existing known methods or tools like bcp, XML Source (in SSIS), Data Import/Export etc,
they all do not provide such function. If you need to check each row for update, there might be not any performance advantage for BULK
operation. In my opinion, dumping the contents first is a reasonable design, especially from performance perspective. I recommend that
you review your requirements to see if you really want update in a bulk load operation. If this is required, you may consider rewriting your
application to implement this function.

SSIS XML Source can automatically generate a matched XSD schema for an XML source, however currently it is simple and will not include
the relationships and keys. You need to manually include the relationships and keys in your schema file. I am not sure if there are third-
party tools supporting this feature. You may contact your application vendor or some third party Dev forums for consulting this.

Appreciate your understanding on this. Please feel free to let me know if you have any other questions or concerns.


Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg RemoveThis @microsoft.com.
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx...tificat

Note: MSDN Managed Newsgroup support offering is for non-urgent issues where an initial
response from the community or a Microsoft Support Engineer within 2 business day is
acceptable. Please note that each follow up response may take approximately 2 business days as
the support professional working with you may need further investigation to reach the most
efficient resolution. The offering is not appropriate for situations that require urgent, real
-time or phone-based interactions. Issues of this nature are best handled working with a
dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================

 >> Stay informed about: SQLXMLBULKLOAD question: Does it INSERT only, or can it UP.. 
Back to top
Login to vote
Bob

External


Since: Feb 08, 2005
Posts: 182



(Msg. 3) Posted: Tue Nov 04, 2008 2:28 am
Post subject: RE: SQLXMLBULKLOAD question: Does it INSERT only, or can it UPDATE as [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sabrina,

I would recommend bulk loading your data to a staging table first and then
using SQL to work out which records need to be inserted or updated. You can
use traditional LEFT JOIN, EXISTS or the EXCEPT operators to work out which
records are already there.

Also, in SQL 2008 you can use the new MERGE statement.

XSD.exe supplied with Visual Studio ( eg C:\Program Files\Microsoft Visual
Studio 8\SDK\v2.0\Bin\xsd.exe ) can create schemas, however they may not
immediately work with SQL Server. I have been opening up the Schemas in
Visual Studios visual designer to see the relationships and then adding them
manually to the xsd file based on the diagram Visual Studio shows me.

I understand there are some tools available, eg SchemaTron, XMLSpy(?) or
related tool, but I have never used them.

Hope that makes sense.

wBob

"Sabrina Veksler" wrote:

> [Using assembly Interop.SQLXMLBULKLOADLib, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=null]
>
> Hello all,
>
> A piece of software that was built for us by a 3rd party uses
> SQLXMLBULKLOADLib to import records from an XML feed into our database. The
> XML feed includes previously-imported records that may or may not have
> changed, as well as new records. When we run the bulkload utility, it
> inserts duplicate records for those previously-imported, so to avoid this,
> we have resorted to emptying out each table prior to running the bulkload
> utility. This is not desirable because the tables often contain records that
> were added through another source, such as the web interface.
>
> I wonder if there isn't a way to accomplish the bulkload without dumping the
> contents first? Each record contains a unique field that can be used as a
> primary key, however, the original developer did not specify the field as a
> primary key in the table. If I set the field as a primary key in the table,
> can the bulkload be configured so that when it processes the nodes in the
> XML file, it updates existing records and only inserts when the record
> doesn't already exist in the table?
>
> Because I didn't originally write this code, I would prefer to keep my
> revisions to a minimum, unless there is a much better way of importing the
> XML feed into our database that I can write fairly quickly.
>
> Also, I was wondering if there is a utility to quickly generate XSD schemas
> to use in the bulkload from the actual tables in SQL Server. I'd like to
> modify our schemas to include the relationships and keys that I've set up
> using the Management Console, but would much rather avoid doing it manually.
> Please advise.
>
> Thank you!
> -Sabrina
>
>
>
 >> Stay informed about: SQLXMLBULKLOAD question: Does it INSERT only, or can it UP.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
SQLXMLBulkLoad with ODBC - I have installed SQLXML 3.0 to use the SQLXMLBulkLoad functionality inside a VBScript code. Now, is it possible to specify in the connection string the data related an ODBC or do I must use only the OLE DB provider for SQL Server? Thanks

SQLXMLBulkLoad - How do I specify the database schema for .. - Hi, If I prefix the table name with the schema it belongs to Example: sql:relation="LOYUS.BURN_REWARDS" I get the error: " Incorrect syntax near '.'. " Evertything works fine if I change it to sql:relation="BURN_REWARDS&quot...

How to define the XML schema for a SQLXMLBulkLoad - Hello everyone. I'm fairly new to SQLXMLBulkLoad and XML-Schemas and have a question regarding how to define an xml-schema to bulk load an XML document that I get from our system. Here's what the XML document looks like: <CatalogDelta> ..

SQLXMLBulkLoad does not upload data to db - I am trying to streamline process of using SQLXMLBulkLoad4Class with VisualStudio wizards. I created tables and relations in dataset wizard. Then used xsd.exe to create class. Then I pass schema from the class output to BulkLoad to created database. Then...

XSD Schema Generates Error from SQLXMLBulkLoad 4.0 - I'm trying to Bulk Load an XML file with a Schema file that maps elements to database tables/columns. I get the error: "The INSERT statement conflicted with the FOREIGN KEY constraint "fk_creditindexannexbondissuer_creditindexannexcomponent&...
   Database Help (Home) -> XML All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]