solving sql server problems for millions of dbas and developers since 2006




Learn more about SQL Server tools





















Top SQL Server Tools






















Simple way to export data from SQL Server  
(Export Wizard)

Overview
SQL Server Management Studio (SSMS) provides the Export Wizard task which you can use to copy data from one data source to another.  You can choose from a variety of source and destination data source types, select tables to copy or specify your own query to extract data, and save your work as an SSIS package.  In this section we will go through the Export Wizard and export data from a SQL Server database to an Excel spreadsheet. 

Explanation
To begin launch SSMS by clicking SQL Server Management Studio from the Microsoft SQL Server program group.  Upon launching SSMS you will be prompted for a connection; connect to the Database Engine.  For demonstration purposes we will use the AdventureWorksDW database.  You can download the AdventureWorksDW sample database from the CodePlex site.

Locate the AdventureWorksDW database in the SSMS Object Explorer; if the Object Explorer isn't visible click the View menu then select Object Explorer:

Right click on the AdventureWorksDW database in the Object Explorer, select Tasks, then Export Data from the context menu to launch the Export Wizard.  Click Next to advance past the Welcome dialog (if shown).  In the following sections we will walk through the wizard step-by-step.

Choose a Data Source

The Choose a Data Source dialog allows you to specify the source of your data.  Since we are running the Export wizard, the dialog will be displayed with the values already filled in as shown below (based on the database you right clicked to start the Export wizard):

Click Next to proceed to the Choose a Destination dialog.

Choose a Destination

The Choose a Destination dialog allows you to specify the destination data source for the data you are exporting.  There are quite a few options available for destinations; the additional inputs will vary based on the destination data source chosen.  For our example we will export our data to Excel then use this Excel spreadsheet as the source in the Import wizard demonstration later in the tutorial.  Fill in the dialog as follows:

Click Next to proceed to the Specify Table Copy or Query dialog.

Specify Table Copy or Query

The Specify Table Copy or Query dialog allows you to choose whether to export data by selecting tables and/or views from the data source or specifying a query to extract data.  Select Copy data from one or more tables or views as shown below:

Click Next to proceed to the Select Source Tables and Views dialog.

Select Source Tables and Views

The Select Source Tables and Views dialog allows you to select the tables and views that you want to export.  For our demonstration we are going to select the DimGeography table as shown below:

You can click the Preview button to view the first 100 rows of the data in the data source as shown below:

You can click the Edit Mappings button (on the Select Source Tables and Views dialog) to review the column mappings from the data source to the data destination as shown below.  If the table does not exist in the destination data source, you can also edit the mappings.

You can click the option to drop and recreate the table in the destination data source; by default this option is unchecked.  If the table does not exist in the destination data source, the Create destination table radio button will be selected and the other radio buttons will be disabled.  If the table already exists in the destination data source,  the Create destination table radio button will be disabled and you can select either the Delete or Append options.

You can click the Edit SQL button to review and/or edit the SQL to create the table in the destination data source as shown below:

Click OK twice to return to the Select Source Tables and Views dialog, then click Next to proceed to the Save and Execute Package dialog.

 Save and Execute Package

The Save and Execute Package dialog gives you options to perform the export operation and to create an SSIS package and save it to SQL Server or the file system as shown below:

For our purposes we will save the SSIS package so we can view it a later section of the tutorial.  Click Next to proceed to the Save SSIS Package dialog.

Save SSIS Package

The Save SSIS Package is invoked if you chose to save your export operation as an SSIS package on the Save and Execute Package dialog.  Fill in the dialog as shown below:

Click Next to proceed to the Complete the Wizard dialog.

Complete the Wizard

The Complete the Wizard dialog shows a summary of the options that you have chosen for the export operation as shown below:

Click Finish to execute the SSIS package.  You can open the Excel spreadsheet and view the table that was exported.  A portion of the Excel spreadsheet is shown below:



 
Sponsor Information







Copyright (c) 2006-2014 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | about
authors | contribute | feedback | giveaways | user groups | community | events | first timer?
Some names and products listed are the registered trademarks of their respective owners.