Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

ERRORFILE and MAXERRORS option with BULK INSERT

By Mohammad Atif,

In the below code MAXERRORS argument defines the total number of records which can be rejected before entire file will be rejected by the system. It is a tolerant level and can be any integer number based on your discretion and requirement

ERRORFILE will define the name and path of the error log file which will contain the erroneous records rejected during Bulk Insert. It will contain maximum of MAXERRORS+1 records.

So in the above script complete file will be rejected only if more than 500 records are rejected during BULK INSERT and 501 records will be logged into Error log file which will be present at the path defined in ERRORFILE argument.

While if less than 500 records are rejected (or no records are rejected) than those records will be logged into error log file while rest of the records will be successfully loaded into the staging table.

Conclusion :

Although these two arguments are rarely used but they can be very helpful if you want to know about the records which are rejected and also to set the tolerance level of the file loaded by defining MAXERRORS value.

Total article views: 697 | Views in the last 30 days: 3
 
Related Articles
FORUM

Reject duplicate Time within 01 minute

Reject Duplicate Time

FORUM

defining "Export to Excel" as a job which runs frequently

defining "Export to Excel" as a job which runs frequently

FORUM

To Fetch Records from a table quickly which is having 10 Lakhs record

To Fetch Records from a table quickly which is having 10 Lakhs record

FORUM

"Invalid argument."

"...could not UPDATE table..."

Tags
bulk insert    
error log    
maxerrors    
 
Contribute