Welcome to SinghVikash blog
Thursday, November 24, 2011
SSIS: From Excel to Sql server table with IDENTITY column
Recently I came across one of the question in a popular forum about inserting data from excel to SQL Table with Identity column values of SQL Table coming from Excel.
This is very much possible that you have a SQL table with an Identity Column and you want to insert data from Excel file and point of interest is values for Identity column of SQL Table are coming from the excel file.
Let us assume we have a SQL Table with following structure:
The ID column is an Identity column. The SQL nature is every time new row will be inserted in this table, the Identity column will populate automatically with the next incremented value.
But in a scenario when the ID column values are coming from Excel File – What should be the behavior?
Let us assume we have a excel file and we have data like this.
We want to store ID column values of Excel sheet in the SQL table “Excel_ID” and want to store it in ID column of SQL table. With SSIS this is pretty simple. All we have to do is create a Package and add a Data Flow Task into it. We need two connections here. One Excel connection to point to our excel file and second OLE DB Connection to point to our SQL Server and SQL table.
Under Data Flow Tab we have following structure
In the OLE DB Destination component we need to check the Keep Identity checkbox.
This will ensure that the Identity check is disabled at the SQL Server table and whatever values are coming from Excel file is stored in the Identity column. After running the package we found that all the values from Excel Column ID have been successfully inserted in the SQL table.
The same thing can be achieved using Execute SQL Task with SSIS.
Popular Posts
-
Mobile Payment is combination of technologies. These technologies include Mobile Wallet providers, Mobile Technology providers, Banking, So...
-
Download PMP - ITTO Table My Journey to PMP Project Integration What is a Project Charter? What is a Project Manageme...
-
How does SilckLogin works? What is Gamification? Biometric ATM in India What is Big Data? What is Google BigQuery...
-
SSRS: How to run SSRS reports on a Web Page? SSRS: How to solve Symmetric key issue with SSRS 2008R2? SSRS 2008R2: How to configure a d...
-
SSIS: How to extract/unzip files to a folder using 7-Zip? SSIS: How to run command Line program and pass arguments to it? ...
-
What do you and Super Computers have in Common? Airtel-Sim Card # 8919... what a hoax? Do you care for your Communication Styl...
-
Ms-Excel Tips How to compare two sheets or files in Ms-Excel? How to use Ms-Excel function SUMIFS()? How to use Ms-Excel functi...
-
Employee Provident Fund (EPF) is an integral part of earning for all working professional in India. All government and private employees ca...