
October 17th, 2005, 12:02 PM
|
|
Registered User
|
|
Join Date: Oct 2005
Posts: 3
Time spent in forums: 41 m 43 sec
Reputation Power: 0
|
|
|
Problems with Identity auto-increment
I am attempting to load several SQL tables from an XML file.
In one of the sub-tables, the primary key is supposed to be an auto-generating number (Due to the lack of unique data). The Identity of this field is set to Yes and the auto-increment and seed are set to 1.
I am using a simple script to read the XML file into the table.
When I execute the script, I get an error that NULL values are not allowed in a key field. In other words, the auto-increment field isn't incrementing. The script will successfully load data from the same file into other tables in the DB.
The primary table is a Customer from the XML file. The customer has a unique key I can use for my customer table. This customer key is the foreign key in a phone table, where I am using the auto-increment primary key.
The XML file can return anywhere from zero to infinite phone numbers. It will allow duplicate numbers. This is why I'm not just using a combo of the phone number/customer ID as the key in the phone table.
Below is the script I am using:
set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.3.0")
objBL.ConnectionString = "provider=SQLOLEDB;data source=<anySource> ;database=<anyDB>;integrated security=SSPI"
objBL.ErrorLogFile = "c:\error.log"
objBL.Execute "c:\schema.xml", "c:\datafile.xml"
set objBL=Nothing
If it will help i can also psot the schema and datafile.
Any help figuring out why the auto-increment key isn't working would be appreciated
|