SQL Server Import and Export Wizard Guide

Written by AndyMcDonald
Reviewed by Johannes Åkesson
May 06, 2022
8 min read

SQL Server Import and Export Wizard

This guide explains how to use the SQL Server Import and Export Wizard to get data into a SQL Server database.

What is the SQL Server Import and Export Wizard?

SQL Server Import and Export Wizard is a simple way to copy data from a source to a destination.  It is most commonly used to get data into or out of a SQL Server database, but it caters to several scenarios.

Although like most Microsoft wizards you are guided through the process quite easily, there are a few key steps in the process that you need to be aware of.  There are also quite a few dialogs to go through in the wizard, some of which need more attention than others.

This guide describes the data sources and destinations that can be used and goes through the step-by-step process by way of an example.

If you are looking for a simple way of importing/exporting data specifically from Excel to SQL Server, try the SQL Spreads Excel add-in.  

What data sources and destinations can be used?

The SQL Server Import and Export Wizard has a number of options available when it comes to selecting the data source and destination.  The main options are:

  • Enterprise Databases (eg Microsoft SQL, Oracle)
  • Open-source database (eg PostgreSQL, MySQL)
  • Microsoft Excel
  • Microsoft Access
  • Text files (eg flat files like csv)
  • Any source for which an ODBC driver, a .Net Framework Data Provider, or OLE DB Provider is available.

The list of available data sources that you’ll see when you run the wizard includes only the providers installed on your computer.  For example, the screenshot below shows the data sources that I can choose from. As you can see, I don’t have MySQL installed, so the provider for the MySQL data source is not available for me.

Wizard - Data source drop down menu

Some example scenarios

The range of options for data sources and destinations means that there are quite a few theoretical scenarios for using the SQL Server Import and Export Wizard.  The following are some of the more common ones:

  • Importing data from a csv (comma-separated values) file to a SQL Server table
  • Importing data from an Excel spreadsheet to a SQL Server table
  • Exporting data from a SQL Server table to an Excel spreadsheet
  • Importing data from an open-source database (eg MySQL) to SQL Server
  • Exporting data from SQL Server to an open-source database

The scenario for importing data from a csv file to SQL Server is particularly common, and we’ve described this process in a previous article.  We’ve also described a simple and often overlooked method of importing data from Excel to SQL Server in this article.

How to use the SQL Server Import and Export Wizard

The SQL Server Import and Export Wizard is installed when you install SQL Server.  It is commonly used from within SQL Management Studio.  It can, however, be downloaded and installed as a stand-alone utility.

The way you launch the application depends on your use case.  For example, if you need to import data from a csv file to a SQL Server table, and you’re not a SQL user, you may launch the stand-alone version.

NOTE: If you launch the wizard from SQL Server Management Studio (select a database, right-click and selection Tasks > Import Data) and try and import from Excel, you may see an error message along the lines of “The operation could not be completed. The ‘Microsoft.ACE.OLEDB.16.0’ provider is not registered on the local machine.” This message appears because SSMS is a 32-bit application and you have a 64-bit version of Excel.  In this case, you’ll need to use the stand-alone version of SQL Server Import and Export Wizard.

Whichever way you launch the application – as a stand-alone or from within SQL Management Studio – the process is the same.

The steps we’re going to work through are summarized below:

  • Start the Wizard
  • Pick the source of the data
  • Pick the destination for the data
  • Specify what you want to copy
  • Configure the copy operation
  • Copy the data

The example scenario we’re going to work through involves importing data from an Excel spreadsheet into a new SQL Server table.  The Excel spreadsheet is here if you want to follow along yourself.  It contains two sheets: one containing a list of students, and one containing a list of subjects.  For this example, we are only interested in importing the list of students into SQL Server.

Excel Students worksheet

Step (1): Start the Wizard

In our example, I am a user that doesn’t use SQL Server Management Studio, so I’m going to launch the SQL Server Import and Export Wizard from my Start menu.

Wizard - Launch app from Start Menu

When you launch the application, the Welcome page is displayed, and you can go ahead and click ‘Next’.

Wizard - Welcome screen

Step (2): Pick the source of the data

Our source data is in Excel, so on the Choose a Data Source page, we can select “Microsoft Excel”.

Wizard - Excel data source

When we select a data source, we need to specify some more information about it.  In this case, we need to provide the location of the Excel file and the version.  We can also indicate that the first row has column headers which should be used as the column names in the SQL Server table.

Wizard - Excel data source configuration

Note: when you select a data source type, the connection settings that you need to provide will change.  For example, if your data source is a flat file (eg a csv file), you need to specify the file location and some details of the file format.

Step (3): Pick the destination for the data

On the Choose a Destination page, we now need to specify the destination for the data.  For our example, the destination is a SQL Server table, so from the destination drop down menu we need to select SQL Server Native Client (you could also select Microsoft OLE DB Driver for SQL Server).

When you select the SQL Server option, the Authentication and Database options are displayed.  In this example we’re going to select ‘Windows Authentication’ and we’re going to copy the data into a table in a new database by clicking ‘New’ in the database section.  If we want to copy the data to a table in an existing database, we can select from the Database drop down menu instead of creating a new database.

Wizard - Choose a destination

Click ‘Next’

Step (4): Specify what you want to copy

The Excel workbook that we are using for this example contains two sheets. We are only interested in the Students sheet for now, so we need to specify that only this will be copied.

First, on the Select Table Copy or Query page, we need to confirm the default option of ‘Copy data from one or more tables or views’.  This just means that we are copying all the data and not a subset of data.  This configuration option is more relevant when you are copying from a SQL database, and you want to write a specific SELECT statement, for example, to filter the data being copied.

Wizard - Specify Table Copy

Click ‘Next’

On the Select Source Tables and Views page, we can do the following to further define how the copy is performed:

  • choose the specific sheet(s) within the workbook that we want to copy
  • (optional) re-name the table that will be created in SQL Server
  • (optional) edit the column mappings

First, we need to tick the first sheet in the list, as that has the student data that we want to copy.  Note that we can copy as many spreadsheets as we like during this operation.  We’re also going to rename the table that will be created in SQL Server.  The default is for the table to be given the same name as the sheet name with a dollar sign appended to it; we’re going to remove the dollar sign.

Wizard - Select Source Table

Next we’re going to edit the column mappings by clicking the ‘Edit Mappings…’ button.

Step (5): Configure the copy operation

First we’re going to change the column names in the destination table so that they use lowercase and underscores.  Secondly, we’re going to change the data type for the ‘date_of_birth’ column from datetime to date.

Wizard - Column Mappings

Once done, click ‘Ok’ to close the dialog and then ‘Next’.

If any of the mappings that we specified may not succeed in the copy process the SQL Server Import and Export Wizard shows the Review Data Type Mapping page. This page will indicate the conversions that the wizard needs to perform to make the source data compatible with the destination.  In our example, there is a warning that the conversion from DateTime to Date for the ‘Date of Birth’ column may lead to data loss.  We don’t need to worry about this warning as it is simply implying that the time portion of the Date of Birth won’t be copied to the new column in the table – this is actually what we are aiming for.

Wizard - Review Data Type Mappings

Click the ‘Next’ button.

Step (6): Copy the data

The wizard now offers you the chance to save the Wizard configuration as an SSIS package in addition to the default option of running the copy immediately.

Note: The SQL Import and Export Wizard uses SSIS under the hood; in other words, each time you run the wizard, you are creating an SSIS package.  This is why you are given the option of saving it for future use.

We are just going to leave the default option ticked and then click the ‘Next’ button.

Wizard - Save and Run Package

The wizard now displays a summary of the steps that we have configured.

Wizard - Complete the Wizard

Click ‘Finish’, and the wizard will now show the final screen, which is the result of the execution.  In our case, the execution was successful, and we can see that 1000 records were copied to the students table in the demo database in SQL Server.

Wizard - Success Message

As a final check, we can open SQL Server Management Studio and check that the data has been copied successfully to the students table in the new demo database.

students table in SQL Server

Summary

SQL Import and Export Wizard offers a comprehensive range of options to copy data from a source to a destination.  In this example, we have shown how to use the wizard for a common use case: copying data from Excel to SQL Server.

If you are looking for a simple alternative to SQL Import and Export Wizard to import and export data from Excel to SQL Server, try SQL Spreads.

 

*This article was originally published on July 20, 2021 and was updated on May 6, 2022 to include additional information about the versions of the standalone utility.

Leave a Reply


No comments yet. Be the first!

Try SQL Spreads for free

Try SQL Spreads during 14 days for free. The free trial is the fully
functional, time-limited only product.
Try Excel Add-In for Free download-image
stars-image
14-days Free Trial. No credit card required.