Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 668 | Views in the last 30 days: 6
 
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 logging    
errorfile    
maxerrors    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones