I have a problem regarding importing data from Excel to SQL. In the import wizard in SQL, the datatype of the field/s is in float (because data contain purely numbers, IDNumber, BiometricNumber and BankAccountNumber) now the datatype of this fields in SQL is varchar and when ever I query or transfer the data to other table the format of value changes to float with e+ digit. Anyone?
2 Answers
First, ensure you are using IMEX=1 in the connection string and that the associated registry key values are set appropriately. For full details, see this article.
Personally, I've never had a problem with scientific notation but a few people have reported similar problems in comments so it might be worth trawling through them. Here's a couple I spotted:
In SQL,
Format([COLUMN NAME], ‘@’) As [COLUMN NAME]In Excel, column has to be formatted (Format cells) as “general” (not formatted as “text”).
I cannot vouch for them, though ;)
2 Comments
IMEX=1, set the registry settings as appropriate, etc? The link to the article is broken but googling "IMEX=1 " and my handle (OneDayWhen) should reveal more details e.g. here: instantpages.ltd.uk/ADODB_WP.htmI changed the data type of the excel column to 'Text' when it was 'General' and the 32 bit SQL Server Import Tool picked it up as an nvarchar.
BankAccountNumberis of typeFLOAT, consider that Access (ACE, Jet, whatever) SQL for Excel has but one numeric data type ;)