Error in importing excel file from SQL Server

catalogue

The text is truncated, or one or more characters do not match in the target code page

Cause

Solution

The value violates the integrity constraint of the column

Blank line

Not set to allow null

I have imported data before without reporting any errors. When importing data again today, I found two errors, as follows

The text is truncated, or one or more characters do not match in the target code page

It’s easy to understand that your data is too large and the size you set is not enough. There may be questions here

As shown in the figure below, if the size can be set, an error will still be reported after setting the size

Cause

This is because in order to determine the field type of the data table, the import and export of SQL server takes the first 8 lines of the excel file. If the first eight strings are less than 255, they are set to nvarchar (255). However, if the length of the records behind excel exceeds 255, an error will occur during import. Even if the length of this field is adjusted when importing the setting mapping

Solution

I added a row to the first row of Excel data, and each field is filled with long characters, so that SQL server will automatically set the maximum value when detecting the first 8 rows

The value violates the integrity constraint of the column

Blank line

This is because the new column behind you is a space. You can select the column behind the last field and delete it to eliminate the possibility of spaces. As long as there is no f beginning such as F10 when importing

Not set to allow null

There is another reason. This field is set to allow null. I cancelled it and the setting is not allowed to be Mull. Then an error is reported that a column violates data integrity
if it is reset to allow null, there is no problem

Similar Posts: