Importing SQL Server table to MS Excel 2007 and Higher

The previous post was about importing Excel to SQL Server. This post will guide you to do the reverse, SQL Server tables to Microsoft Excel. The slideshow below would guide you through the steps involved in importing SQL Server table to MS Excel 2007 and higher versions.

The steps involved are

  1. Open a fresh sheet in excel
  2. Go to the data tab in the ribbon
  3. Select “From SQL” in the “From Other Sources” menu
  4. A Wizard will open. Follow the steps shown in the above slide show for selecting the SQL Server database and table and click finish
  5. This will import the desired table to your excel sheet.

This slideshow requires JavaScript.

In the same way, we can also import the other data sources to Microsoft Excel. Hope it helps. Happy learning!!


Importing MS Excel to SQL Server Database

The Screenshots below guides you through importing your MS Excel file into your SQL Server Database.

The Steps involved are

  1. Connect with your SQL Instance
  2. Create a new database to store the excel tables
  3. Right-click the DB and Select Tasks >> Import Data
  4. Import Wizard will Open
  5. Select MS Excel as the Data Source
  6. Select the excel file path and the version
  7. Select the database in which excel has to be exported
  8. Select the radio “Copy data from one or more tables or views”
  9. Select the tables to be imported
  10. Complete the wizard and click finish

This slideshow requires JavaScript.

Will share how to import data from SQL database to MS Excel in the next post. Happy Learning!!!

Handling “An Item with the same key has been added” Exception in C#

“An Item with the same key has already been added” is quite a common exception while working with Dictionary object in C#. It arises when you attempt to add a same key to the dictionary object that has a same key. In those cases, you can either update the value corresponding to the key. This can be done as given in the below screenshot.

Same Key Exception

If you do not want to update your existing Key-Value pairs, you can create a new instance to the Dictionary object and proceed with adding the Key-value pair of your choice. This will also prevent the exception.Please find the screenshot below for more details.


Happy coding folks!