Pages

Monday, July 4, 2011

Import Data from Excel to SQL using MS SQL server 2008's Import Export wizard

This blog explains how to import data from excel to an SQL Server.
For this we use Import Export wizard provided by MS SQL server 2008. To run this wizard go to start -> All Programs -> Microsoft SQL Server 2008 -> Import and Export Data (32 bit).
This opens the following wizard.

Now click on next to start with import. This starts with the following wizard :
Through this wizard specify the source of the file. In the data source select Microsoft Excel, and give the path of the Excel sheet. This gives the following wizard
 Now click on Next. Here we need to specify the Destination. Provide the destination as SQL Server Native Client, Server name, Database.
Once the source is specified click on next. And now set whether its table copy or query copy. For sample i have selected the Table copy.
No on clicking the Next, it asks for the Source tables and views. Select the source "Sheet". This would automatically create a new table in the sql server and gets binded to the Destination column. Or we can specify any existing table in sql server as well. But the data type of the excel and the sql server should match for mapping.

Now the next step is to save and run the package. So click next, and in the next wizard check the Run immediately check box. and give next. In the next(Complete wizard) click on the Finish button. This will start the execution process.

This ends up the transfer process. And produces the report like the following fig.
Now when you go to SQL Server, a new table with the data in the excel sheet gets binded under the Database specified....

No comments:

Post a Comment