We have SQL Import and Export Wizard in SQL, which can help to import or export data from various sources to different destination using Wizard. In this example, we are going to export DimGeography table data present in the Adventure Works DW 2014 SQL data base to Geography text file present in the local hard drive using SQL Import And Export Data Wizard.
Export Data from SQL Server To Flat File Using Import And Export
In order to Export Data from SQL Server To Flat File Using Import And Export Wizard, Double click on SQL Server Import and Export Wizard tool (you can find in start -> All Programs -> Microsoft SQL Server 2014 -> SQL Import and Export Data Wizard). It will open SQL Server Import and Export Data Wizard. First page is welcome page
If you don’t want see this page again then Please tick the check box “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 SQL data base so we are selecting SQL Server Native Client as our source and I am using my localhost instance as sever name.
Select the source data base 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 SQL 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 data into text file so we are selecting Flat File Destination as our Destination
Then we have to select the text file from our local drive
From the above you can observe we are creating the Geography text file. Next, 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 normally use because there will be unnecessary columns in every table so it is better to avoid them or selecting data with condition.
For the time being we are selecting every row so we selected the first option. Click Next button
This page is used to select the source table from SQL data base you want to use as source. Here we are selecting DimGeography table. Click on preview button to check the incoming data flow
Specify the Row delimiter and Column delimiter you wish to. Click on 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 SSIS package
- Name: Change the package name as you wish
- Description: Write your own 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 Wizard
From the above you can observe the status: Success and Message.
Let’s navigate to file system address we provides and check for the file name Geography. Double click on text document to check the result
Thank you for Visiting Our Blog