[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2007-04-09
9
Medium Priority
?
1,040 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18876220
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
ID: 18876272
how do I do that? I use ms-excel 2005.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18876293
how do you import actually?
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 1

Author Comment

by:super786
ID: 18876316
In SQL Server, go to schema, right-click, import data, select source: excel, browse for file, append to respective table, done.
0
 
LVL 1

Author Comment

by:super786
ID: 18876540
Hello?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18876581
>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
ID: 18877596
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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1500 total points
ID: 18878216
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
ID: 23195839
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 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