Thursday, December 14, 2023

SQL Server Import Excel file into Database

In this post we will import an excel file into SQL Server database using SSMS tool. SQL server allows you to import different data sources such as flat files CSV, excel file etc. Use the following steps to import an Excel file into SQL Server.
  1. Open the SSMS. 
  2. Login to SQL Server. 
  3. Press F8 to view Object Explorer window. 
  4. Select the database in which excel file to be imported.  
  5. Right click the database.
  6. Click Tasks menu item and then click Import Data menu item.
  7. SQL Server Import and Export Wizard dialogue box appears. Click the Next button.
  8. Select the correct data source from the drop down. To import excel file we use Microsoft Excel from the dropdown. Select the Excel version and then Click the Browse button to pick the Excel data file. Click the Next button.
  9. Now we choose the destination in the Destination textbox. We select SQL Server Native client in the server name. Use Windows authentication or SQL server authentication and click the Next button. 
  10. Select first radio button 'Copy data from one table or view'. Click Next button. 
  11. Click Edit Mapping to correct the data types of table, if required. You can leave it otherwise. Click Next button twice and finally click Finish button. The table will be generated in the selected database. Click the Close button. 
  12. Refresh the selected database. You get the table into the Tables folder. Excel generated table name is suffixed with dollar symbol. You can rename this table to remove dollar symbol.
Based on the excel file, table will be created in the database.

In the next post we will learn about how to Generate Insert Query from table SQL Server.

No comments:

Post a Comment

Hot Topics