Click to See Complete Forum and Search --> : Using sqlxmlbulk load and check for existing records


emmetmurray
06-24-2008, 09:00 AM
Hi,

I'm using sqlxml bulk load 3.0 to import some xml. I'm just wondering if there is a way (either in the mappng schema, or the script itself) to check if the record already exists? or if theres any other suggestions on how i could update my table from the xml.

script

Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data source=ip;database=products;uid=sa;pwd=test"
objBL.ErrorLogFile = "c:\xml\error.log"
objBL.Execute "c:\xml\productmapping.xml", "c:\xml\products.xml"

MsgBox "XML imported to sql server!", "0", "XML imported to sql server"

Set objBL = Nothing



schema

<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql" >

<ElementType name="ID" dt:type="int" />
<ElementType name="event_token" dt:type="char" />
<ElementType name="event_desc" dt:type="nvarchar" />

<ElementType name="event_list" sql:is-constant="1">
<element type="event" />
</ElementType>

<ElementType name="event" sql:relation="products">
<element type="event_token" sql:field="event_token" />
<element type="event_desc" sql:field="event_desc" />
</ElementType>

</Schema>

thanks