Skip to main content

Methods of Data Pull from Excel to Database Tables

Methods of Data Pull from Excel to Database Tables:
There are several methods that can be used to pull the data from an excel sheet into a database table.
  1. Using SQL Server's Import and Export wizard that lets us choose the excel file from which the data to be pulled. Each sheet of the excel file can be distinguished from the sheet name during the mapping step in the wizard. A sheet, for example sheet 1 is referred as Sheet1$ and so is Sheet2$ and so on.
  2. Creating an SSIS package, that lets us choose the data source to be an excel file and the data destination that would be a database table through a OLE DB Connection properly set up.
  3. Another way would be using a linked server. Here, select the OLE DB provider to be Microsoft Jet 4.0 OLE DB Provider. Select the Product Name as Excel, Data source is the full path of the Excel file and the provider string is Excel 8.0. This configuration is as mentioned in the below picture.


 And later, click OK, which will complete the configuration of the Linked Server for the Excel file. To import the data to a table we can use a select into query as

SELECT * INTO data_frm_excel FROM EXCELLINK...Sheet1$

This select statement selects the data from the linked excel file from sheet 1. EXCELLINK is the linked server name we have chosen here which could be given as ever required on their own choice.

And there are other methods that can be used to load the data to tables in the same way using Programming concepts which aren't explained here. For further reference, go to the following link.

http://support.microsoft.com/kb/321686

Comments

Popular posts from this blog

Digging into a long running job

Revisiting the blogger to finally start again blogging about the SQL Server after a long long time.  This post is on analyzing and digging into what is causing a job significant time to complete. This will be a basic level of approach and I wish, I could have done better. But, its was enough in my case to get to a conclusion, with the knowledge I equip.   Issue : A job that's scheduled to run every three hours, was running for more than 48hours. Average job run time, 1.5hrs.  Analysis : First and foremost thing to do, is to find out on what session id is the job running on the instance. You may use the below query to fetch the session id of the job from the job name. declare @Var1 varchar(36) select @Var1=substring(REPLACE(CAST(job_id AS VARCHAR(36)),'-',''),17,16) from sysjobs where name =' JOB_NAME ' select * from sys.sysprocesses where program_name like '%'+@Var1+'%' You may get a single row or multiple rows with ...

Deferred prepare could not be completed

This is usually an error that is encountered while querying a remote database on a different server instance which says OLEDB provider "SQLNCLI" for linked server "ABCD" returned message "Deffered prepare could not be completed" Msg 8180, Level 16, State 1, Line 1 Statement(s) could not be prepared. This is the way I could rectify, though this is not the lone mistake that gives this error every time. Just set the default to the database that is being querying to the user through which the Linked server is connecting to the database.

Incorrect SET Options with Filtered Indexes

Rebuild Index|Create Index|DML on a Table with Filtered Index fails with the error: The following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. [SQLSTATE 42000] (Error 1934).  The step failed. The Operation above might succeed when its through SSMS. But, would fail when the operation is from a SQL Agent Job. This is because, SQL Agent by default, do not have the SET Options enabled (ON). They are OFF. Reason: The following are the SET Options that are needed while operation on a table with a filtered index. Required SET Options for Filtered Indexes The SET options in the Required Value column are required whenever any of the following conditions occur: Create a filtered index. INSERT, UPDATE, DELETE, or MERGE operation modifies the data in a...