Home » excel » sql server – Truncation errors trying to import from Excel

sql server – Truncation errors trying to import from Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m trying to import the NDC database that you can download here: http://www.fda.gov/drugs/informationondrugs/ucm142438.htm

When I initially tried to import the excel in the zip file it complained about the format, so I started with a blank excel, and imported it into excel from the txt file.

I’ve created a table to import the data into and set all the columns to nvarchar(MAX). The column it complains about is the SUBSTANCENAME column. I checked, and the longest value in that column is about 2700 characters.

My understanding is that the nvarchar(MAX) should easily hold that much. I’m not sure what to do about this other than changing that column to a text field. Should that fit into that column how it is?

I’ve tried setting it to ignore errors, but as far as I can tell that does nothing, at least it never seems to ignore them when I try.

How to&Answers:

How are you importing the data into the SQL Server table? If I remember correctly, SSIS uses the first 5 or 10 rows of the Excel file to determine the datatype and length. I remember I had to make a change to the registry in order to get a larger sample size
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel
The TypeGuessRows entry can be modified to get a larger sample size.
That is assuming you are using SSIS – but if you are using SQL Server Import then it would be doing the same thing as well.

<a href="https://exceptionshub.com/category/sql-server”>More Answers>