Home > SQL Programming > Importing Excel to SQL: The value violated the integrity constraints

Importing Excel to SQL: The value violated the integrity constraints

December 21, 2010

Another interesting thing happened today when i tried to import the  data from Excel to SQL Database i got an error that the value violated the integrity constraints. The error message as like below.

Messages
Error 0xc0202009: Data Flow Task: An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: “Microsoft SQL Native Client” Hresult: 0x80004005 Description: “Unspecified error”.
(SQL Server Import and Export Wizard)
Error 0xc020901c: Data Flow Task: There was an error with input column “Showtext” (52) on input “Destination Input” (42). The column status returned was: “The value violated the integrity constraints for the column.”.
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task: The “input “Destination Input” (42)” failed because error code 0xC020907D occurred, and the error row disposition on “input “Destination Input” (42)” specifies failure on error. An error occurred on the specified object of the specified component.
(SQL Server Import and Export Wizard)

Problem Cause

When you try to import the excel to sql using ssms ,ssms create the automatic sql script to create a table. in which few of the data types (bit,etc) will not allow nullable value into the column that is the reason it is causing the above error.

Solution 

In my case from my excel data there are many null values or the empty values are there so i need to change the column to allow null values. after that i try to import the data it worked fine for me.

Advertisements
Categories: SQL Programming
%d bloggers like this: