SQL 2012 Import from Excel fails when blank

I was given a spreadsheet with item numbers and alternate item numbers. There are about 800 rows in the spreadsheet and it looks like this:

ITEMNMBR,ALTITEM1,ALTITEM2,ALTITEM3,ALTITEM4
100842,100942,10142,10242,10342
100843,100943,10143,,10344
100844,100944,10144,10244,,
100845,100945,10145,10245,10345
ETC

I am just clicking Tasks->Import inside SSMS. ALTITEM1 and ALTITEM2 import fine because no rows are missing any values and they correctly came over as nvarchar(255) as all columns are defined as text in Excel. However, ALTITEM3 and ALTITEM4 for same strange reason get converted to float even if I tell SSMS to treat them as nvarchar. How do I prevent this conversion? If I do tell it to use nvarchar the import does not work at all because it tells me invalid conversion. If I do not tell it to convert them all the values come over as NULL.
LVL 1
rwheeler23Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
You could try to fix all that.

Or you try a quick work-around.  Add a dummy first row to the spreadsheet and put a string of 50 x's (xxxxxxx...) in the columns that are now being treated as float.  That should force Excel to treat them as (n)varchar.  Then, after you load the spreadsheet into SQL, delete that row.
0
rwheeler23Author Commented:
That is what I tried and that failed. I even tried inserting a bunch of rows with X's.  Isn't there a setting where you can tell it to read some many records as it tries to determine the column type? The only fix I had for now was to create 2 additional spreadsheets and in each column eliminated all blanks.
0
Scott PletcherSenior DBACommented:
Supposedly there is a registry setting to control the number of rows, but I've never been able to get it work consistently.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwheeler23Author Commented:
Thnaks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.