We have Import and Export Wizard in SQL, which can help to import or export data from various SSIS sources to different destinations using Wizard. In this example, we are going to export DimGeography table data present in the Adventure Works DW 2014 database to Geography text file present in the local hard drive.
Export Data from SQL Server To Flat File Using SSIS Import And Export
To Export Data from SQL Server To Flat File Using SSIS Import And Export Wizard, Double click on Import and Export Wizard tool, you can find in start -> All Programs. It will open the SQL Server Import and Export Data Wizard. The first page is a welcome page
If you don’t want to see this page again, then Please tick the checkbox, “Do not show this starting page again.” For now, click Next
Choose a Data Source Page: This page is used to configure the source information. Our source is the SQL database, so we are selecting the Native Client as our source, and I am using my localhost instance as a server name.
Select the source database from the list. Let us select the Adventure Works 2014 here.
Authentication: Here, we are using windows authentication. But in real-time, your organization or company will provide the authentication credentials to access the database. In that case, you have to change the radio button to server authentication and provide the user name and password.
Choose a Destination: This page is used to configure the destination information. Our target is to save the Export Data from SQL Server To Flat File Using SSIS Import And Export Wizard. So, we are selecting Flat File Destination as our Destination
Then we have to choose the text file from our local drive
From the above, you can observe we are creating the Geography text file. Next, Please select the Format we are going to use
If you want the text file to include column name in the first row, then tick the checkbox “Column name in the first data row”. If not, uncheck it.
Click Next button
Specify Table Copy or Query: Here we have two options
- Copy data from one or more tables or views: Use this option to select from existing tables or view (All the columns data)
- Write a query to specify file data to transfer options: This is the option regularly use because there will be unnecessary columns in every table. So it is better to avoid them or selecting data with the condition.
For the time being, we are selecting every row. So we chose the first option. Click Next button
This page is used to select the source table from the database you want to use as a source. Here we are choosing the DimGeography table. Click on the preview button to check the incoming data flow
Specify the Row delimiter and Column delimiter you wish to. Click on the Edit mappings button to change the types and sizes.
Save and Run Package: This page gives us the option to save the package in either SQL server or File system. For the time being, I am selecting file system
Save SSIS Package: Provide the address to save the package
- Name: Change the package name as you wish
- Description: Write your description
- File Name: Select the file name by clicking on the Browse button and navigate to the appropriate location.
Click finish button to complete the SSIS Wizard. Observe the status: Success and Message.
Let’s navigate to the file system address we provide and check for the file name Geography. Double click on a text document to check the result. We have successfully exported Data from SQL Server To Flat File Using SSIS Import And Export. wizard.