Preparing excel workbook for importing into SQL - sql

I am trying to import some data into sql using the import and export data wizard. In excel i have a column with 8 numbers. However when i get these in the import wizard said column is displayed as being double. and when i import it i get overflow errors. I then go back to excel, select the cell, format them as being a number with no decimal places. Then i go to the "edit mappings" in the import wizard and change the destination to numeric(8,0). I get those overflow errors as well.
Would like if i could get a way to better format the data in excels to import better
Thank You

You can import your table into a temp or staging table with a larger data type; validate and clean your imported data; then load it into your real table. If you can't always enforce the data type in your Excel doc, then make it easier on the server side to import your data, then manipulate it there.

I had a project that ran into this problem last year.
What I ended up doing is I imported the data from Excel to Access. Then import from Access to SQL. I don't remember the specifics, but it solved most of my issues.

I don't think the format of the column in Excel makes a difference to the import process (although I could be wrong about that.)
My guess would be that either one of your numbers is 9 or more digits, or one of them has a very small fractional component that's small enough not to appear in Excel but which the wizard detects.
You're certain that this column is the one with the overflow errors, by the way? Does it tell you what row has the problem?

Related

VBA Access Transfertext Import Errors

I would like to import a spreadsheet to an access database, on column has ages 1-89 plus another that's says 90+ which in turn create a Import Error. Using the DoCmd.TransferText, is it possible to import everything as it is including 90+ in the column of all other numbers?
If you import data into a table that doesn't already exist, Access will create one for you. It automatically determines the data type of each column based on the first few rows that are imported. If your source data contains a mixture of data types in one column, then you may experience this error.
There are 2 solutions:
Build the import table to be of the correct data type for your data (i.e. specify that the age column is Short Text). Then import to the pre-defined import table.
Ensure that the CSV or Excel file stores each age as a string i.e. "20" instead of 20 (in Excel, format the cell as Text, so it is left aligned or start cell contents with an apostrophe '20 or use formulaic notation ="20").
You could do either of those things, but it would be better to do both of them if possible.

MS SQL Server generates duplicate tables when importing an Excel file

Anyone knows why a duplicate table will be generated when using SQL Server Import and Export Wizard to import an Excel file? For example, a table named LN$LN appears after the original table named LN$
Thanks!
I think there may be a hidden sheets in your excel
can you make a try like below.
Was just having an issue similar to this and then noticed the following in the excel spreadsheet I had been given. There was an entire duplicate of the data set hiding in the collapsed rows here only visible by the number color change and extra line. Oddly, unhide and cell height did not seem to work on this, but I was able to expand them back out and delete them by selecting above and below and double-clicking over it (just like you can for the column width to expand to fit).
If anyone is experiencing duplicate or unexpected data appearing during import check for something like this as well. Note that it can also appear in the middle (it does not have to be at the end) as I found several of these in the file I was given.

Import a CSV file into Access using VBA

I need to use VBA to import a large CSV excel file into an Access table. The delimiter is "" (double quotes) except for some reason the first value is followed by " (only one quote) instead of two like every other value. The first row contains the column headers and are delimited the same way. At the bottom I have attached an example.
The CSV files are generated automatically by an accounting system daily so I cannot change the format. They are also quite large (150,000+ lines, many columns). I'm fairly new to VBA, so as much detail as is possible would be much appreciated.
Thanks in advance!
Example of format
That doesn't sound like a CSV file. Can you open it in Excel, convert it to a true CSV, and then import that into Access? You will find many VBA-driven import options at the URL below.
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm
Also, take a look at these URLs.
http://www.erlandsendata.no/english/index.php?d=envbadacimportado
http://www.erlandsendata.no/english/index.php?d=envbadacimportdao

SSIS imports wrong numbers of data from excel

I am currently creating an SSIS package which imports data from excel to sql server. My problem now is I have 4998 rows on my excel source and everytime I try to run my SSIS package, it imports 5,010 data. I don't know where did it get the excess data. how can I fix this? can anyone help me please. Thanks!
Excel does this sometimes. It keeps track of the "data range", which sometimes extends beyond the actual data that exists. This "data range" is what SSIS will import.
If you look at your import table, you should be seeing 12 blank rows. Unless you've imported the header row, if any, as a row. That's another possibility: does your Excel sheet have multiple header rows (many do)?
It is possible to apply some kind of SQL to Excel datasources, but I avoid it because I don't trust Excel's handling of data. The solution is probably to identify a key column, which should always have a non-NULL, non-blank value of a certain type (e.g. a number or a date) in every "real" data row. Then delete rows that break this rule from your import table.
Excel importing is no fun!

Help Importing CSV file with Variable Columns per Row into SQL Table using Import tool or SSIS

I am stuck with a CSV file with over 100,000 rows that contains product images from a provider. Here are the details of the issue, I would really appreciate some tips to help resolve this. Thanks.
The File has 1 Row per product and the following 4 columns.
ID,URL,HEIGHT,WIDTH
example: 1,http://i.img.com,100,200
Problem starts when a product has multiple images.
Instead of having 1 row per image the file has more columns in same row.
example:
1,http://i.img.com,100,200,//i.img.com,20,100,//i.img.com,30,50
Note that only first image has "http://" remaining images start with "//"
There is no telling how many images per product hence no way to tell how many total columns per row or max columns.
How can I import this using SSIS or sql import wizard.
Also I need to do this on regular intervals.
Thank you for your help.
I don't think that you can use any standard SSIS task or wizard to do this. You're going to have to write some custom code which parses each line. You can do this in SSIS using VB code or you can import the file into a staging table that's just a single column to hold each row and do the parsing in SQL. SSIS will probably be faster for this kind of operation.
Another possibility is to preprocess the file using regex or a search-and-replace command. Try to get double-quotes around the image list then you should be able to import the whole file fine, with the quoted part going into a single column. Catching the start of the string should be easy enough given the "http:\" for which you can search. Determining where the end quote goes might be more of a problem.
A third potential solution would be to get the source to fix the data. Even if you can't get the images in separate rows (or another file with separate rows, which would be ideal), maybe you can get the double-quotes added from the source as part of the export. This would likely be less error-prone than using the search-and-replace method.
Good luck!