Solved

Import excel spreadsheet into Sql Server schema - numbers become exponentials: Why? Fix?

Posted on 2007-04-09
9
984 Views
Last Modified: 2011-10-03
I have an excel spreadsheet that I import into a table in a SQL server schema. Once I import it, all the data appears perfectly EXCEPT a column (record_num), which has 6-8 digit numbers. On the Excel sheet this column displays the numbers just fine, but once I import it into a SQL table, the data in that column looks like this : "2.12043e+006" (instead of 2120426)

Now I looked at the SQL table's design and the data type is set to "varchar: 100"

If I re-format the column in excel as general, text, or number - I still get exponentials instead of the ACTUAL 6 or 8 digit number.

What am I missing? There's over 400 rows of data.
0
Comment
Question by:super786
  • 4
  • 4
9 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
can you try to add the following to the extended properties of the connection string to the excel file:
IMEX=1

should solve the problem
0
 
LVL 1

Author Comment

by:super786
Comment Utility
how do I do that? I use ms-excel 2005.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
how do you import actually?
0
 
LVL 1

Author Comment

by:super786
Comment Utility
In SQL Server, go to schema, right-click, import data, select source: excel, browse for file, append to respective table, done.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:super786
Comment Utility
Hello?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>Hello?
you might consider reading my comments about such behaviour in my profile:
http://www.experts-exchange.com/M_302115.html

anyhow, is this import task to be a one-shot operation, or a task to be repeated?
in first case, you might consider using ms access with a linked table to the SQL Server table, copy the data from excel and paste into the table using the linked table in access.

if it is a task to be repeated, you should consider checking out SSIS, where you can specify some connection parameters when importing (excel) files, ie the IMEX=1 I mentionned above.
0
 
LVL 1

Author Comment

by:super786
Comment Utility
Ok now its giving me another error. Seems as though now the record_num is working fine (I changed it to text). But the other problem I am having now is the date_column. My SQL design for the table for this column is datetime :8, as it also is on the spreadsheet. I try and import it and now it says the date_column is in incorrect format. I tried text, general...no help. I tried saving it as csv, but still doesn't work.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
in general, I highly disrecommend to load directly to production tables.
always load into a staging table first (which has only varchar columns), validate and clean the data in there, and convert from there to the true table.
will help to avoid / solve many, if not all, problems like the one with date fields.
exception is with data sources that are "sure" and fixed.
0
 

Expert Comment

by:BritKev
Comment Utility
MS Access - I had the problem of Social Security Number getting converted to exponential format when importing from Excell spreadsheet, even though the Excel column 'Format' was defined as 'Text' as was  the Access table field. In fact all but the SSNs starting with zero were messed up - that's why I didn't notice anything was wrong for a while, because the first few screens looked good.  I found that if I created the SSN column in Excel as 'Text' ( so I could retain leading zeros) and then changed it to 'General' before I saved it and imported to Access, that seemed to work. Hope this helps somebody.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now