SSIS Package Error
You are using SSIS package to load data into SQL table and suddenly you get the error “The value violated the integrity constraints for the column”. It does not give enough information of why the error occurred.
Root Cause for Error
SQL Server has following integrity constraints
- Primary Key
- Foreign Key
- Not Null
If you are trying to insert data but any of above mentioned integrity constraints are not satisfied, it will throw an error. For example
- Value you are trying to insert in primary key is either null or already exists – violates Primary Key constraint
- Value you are trying to insert in foreign key is either null or does not exists – violates Foreign Key constraint
- Value you are trying to insert is null but column is defined as Not Null – violates Not Null constraint
- Value you are trying to insert already exists – violates Unique constraint
- Value you are trying to insert is not acceptable – violates Check constraint
If Source is Database Table
If the source a database table, make sure that you have correct data for each column.
If Source is Excel Spreadsheet
If the source is Excel spreadsheet, it is a bit tricky to find the root cause. One reason you will get an error is because blank rows exists somewhere in the middle of data or at the very end.
Even though visually you will not be able to verify if the blank rows exists in Excel or not, try to select all the blank rows all the way up to the last Excel row, right click on the selection and press “Delete” to delete it, save the file and rerun the SSIS package again.
Hopefully this would solve your problem.