SSIS Import Excel Document Using Column Position, Not Name - sql

I was wondering if it was possible to import Excel documents using SSIS by referencing a column by its position? For example, import columns A,D,M,AA, etc. I ask because I need to load in several Excel documents from a third party. Each document contains the same data type in the corresponding columns, except the column names are different for each document.
Thanks!

Yes but you won't be using the Excel driver and connection manager. Instead, you will use the OLE DB driver and write a SQL Query against the file. For anything but the most basic Excel files, this is my go-to approach for importing data out of Excel.
Various incarnations of my approach
Excel Source as Lookup Transformation Connection
script task in SSIS to import excel spreadsheet
Import a single Excel cell into SSIS

Related

Import sheets from xls file into separate tables SQL

Is there a way to import excel file that has multiple sheets into a database? (each sheet is a separate table) Or Do I have to do that maunaly with csv?
Yes, when using Import Wizard you specify the source as Excel, the destination as your SQL DB and then select the sheet of the Excel workbook to use.
Please be careful with Excel in the data mapping, Excel will 'auto choose' a data type based on the first 10 (?) rows. If you have a column with all numeric at the top, but then some text values later on that data will not load.

Missing columns while importing excel data into SQL Server 2012

I am moving Excel data into SQL Server 2012 using the Import/Export wizard.
The Excel sheet has 377 columns, but when I am importing the file into SQL Server, only 255 columns are appearing in the table. Where are the rest of the columns?
Unfortunately this is a limitation of the ACE driver so not easy to overcome.
An easy solution that I see is to open up the Excel sheet in Excel, then save as CSV. Then use the Import wizard to import the CSV.
I'm not sure if you're aware of this, but the Import/Export wizard is actually using SSIS. In one of the last screens, you have the option to save the SSIS package (.dtsx).
To get the workaround with the names ranges to work, you'll first need to import the two ranges in two separate tables and then join them together to fill up the final table.
Maybe this helps as well: http://blogs.msdn.com/b/dataaccesstechnologies/archive/2011/01/22/importing-excel-2010-data-into-sql-server.aspx

Importing Excel Data With Images into SQL Server

I wish to import data from an Excel File into SQL Server 2012. The Excel file has one column which contains an image in each row.
So when I use the SQL Server Import & Export Wizard, it imports everything fine except the pictures.
Thank you.
It's not possible to import images from an Excel file into SQL Server using the Import & Export Wizard.
This is partly due to the fact that images are actually not located inside the individual spreadsheet cells. In Excel, images are stored as free objects (granted, you can anchor an image to a cell, but this is pure layout - not data).
To be able to do what you want, you'd probably have to create some custom VBA code, to loop through each image in your spreadsheet, serialize the image into binary format and then write it to your SQL database table, along with the name of the image object. You will probably have to do this on an image-by-image basis, inserting one record at a time, so hopefully, your Excel spreadsheet does not contain too many images.
Binding each image record to the cell record will be a problem on its own, but hopefully, the images in your Excel file have been named in a way, that enables you to match them with their corresponding data record.

Bulk Exporting Non-Tabular Excel Data into a Database

We're facing a massive data migration that consists of about 1500 Excel Spreadsheets that were used to print out data. Because they were designed to be visual, the data is stored in several fields throughout the spreadsheet. I'm looking for a way to map out those fields, and then do a bulk import to bring all of it into a single large table (or series of tables, if needed).
If it was all in a table format, this wouldn't be a problem - but I'm not sure of any way to import, and somehow map the fields to be imported).
Any thoughts or ideas?
If we're speaking in generalities, I'd look at performing this task via a .NET program and use the ACE OLEDB provider to query the Excel data. Then use the language of your choice to parse the data into something more manageable and write to the database. This approach worked well to import some very non-tabular data into SQL Server.
Quick list of SO questions with C# examples of code to query Excel.
How to query excel file in C# using a detailed query
OleDB Read Excel decimal value
Importing excel files in c#

BCP utility to create a format file, to import Excel data to SQL Server 2008 for BULK insertion

Am trying to import Excel 2003 data into SQL table for SQL Server 2008.
Tried to add a linked server but have met with little success.
Now am trying to check if there's a way to use the BCP utility to do a BULK insert or BULK operation with OPENROWSET, using a format file to get the Excel mapping.
First of all, how can I create a format file for a table, that has differently named columns than the Excel spreadsheet colums?
Next, how to use this format file to import data from say a file at: C:\Folder1\Excel1.xsl
into table Table1 ?
Thank you.
There's some examples here that demonstrate what the data file should look like (csv) and what the format file should look like. Unless you need to do this lots I'd just hand-craft the format file, save the excel data to csv, then try using bcp or OPENROWSET.
The format file specifies the column names for the destination. The data file doesn't have column headings so you don't need to worry about the excel (source) cols being different.
If you need to do more mapping etc, then create an SSIS package. You can use the data import wizard to get you started, then save as SSIS package, then edit to your heart's content.
If it's a one-off I'd use the SQL data import size, from right-click on database in mgmt studio. If you just have a few rows to import from excel I typically open a query to Edit Top 200 rows, edit the query to match the columns I have in excel, then copy and paste the rows from excel into SQL mgmt studio. Doesn't handle errors very well, but quick.