Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Problem with Automated Job

Author  Topic 

jej1216
Starting Member

27 Posts

Posted - 2006-07-25 : 10:51:52
I have a Job I created by clicking on the table and importing data from a .csv file and then scheduling the Job. It ran correctly each night for weeks, then started failing with the error:

"Error string: Violation of PRIMARY KEY constraint 'PK_CENSUS_ACTUAL_TBL'. Cannot insert duplicate key in object 'CENSUS_ACTUAL_TBL'. Error source: Microsoft OLE DB Provider for SQL Server"

When I click on the Job and run it manually, without changing the .csv file or the Job, it runs to success. There are no duplicate keys in the file, which is why I can run it to success manually, but what would cause the Job to think it has duplicate rows when automated? The table structure has 2 keys - Facility and EFFDT, and the .csv file has 6 rows of data, and each time it fails the file has unique Facility/EFFDT rows.

TIA,

Joe

jej1216
Starting Member

27 Posts

Posted - 2006-07-25 : 12:33:30
I believe I may have this figured out. It was a timing issue. The .csv file was being built around 4AM, but my load program was loading at 4AM. So, sometimes the file was updated prior to my load but other times my load fired before the update, so it failed with the duplicate key error - and that's also why when I manually ran it at 8AM it succeeded since the file by that time had updated. I set the load to run at 5AM, which should fix the issue.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-07-26 : 02:51:22
Always a good feeling to solve your own problems

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page
   

- Advertisement -