Nisarg Upadhyay
Save SSIS Package

Copy SQL Databases between Windows 10 and CentOS using the SQL Server import-export wizard

September 21, 2022 by

In this article, we will learn how we can backup and restore the SQL Database in CentOS. This article is the third article on the topic Manage SQL Server on CentOS. In my previous article, we learned how to copy data SQL database between windows 10 and CentOS Linux using SQL Server management studio.

In this article, we will learn how to copy databases using SQL Server 2019 import export wizard. I have restored the stackoverflow2010 database on my workstation.

I have created a virtual machine and installed CentOS 8.0. The IP Address of the virtual machine is 192.168.1.47. I have created an empty database named DevStackoverFlow2010 on the SQL Server instance of CentOS.

Before exporting the data, let us see the row count of the badges table. Run the following query:

Query Output

Row count of Badges table

Now, let us begin the data transfer process. Open SQL Server 2019 import export wizard. The first screen is an introduction and task to be performed by the import-export wizard. Click Next.

Import export wizard

On Choose a Data Source screen, you can configure the source connection details. Specify the following parameters to connect to the source database server.

  1. Data source drop-down: SQL Server Native Client 11.0
  2. Server Name: Nisarg-PC
  3. Authentication: Windows Authentication
  4. Database: Stackoverflow2010.

Select source SQL database

On Choose a Destination screen, you can configure the destination connection details. Specify the following parameters to connect to the source database server.

  1. Data source drop-down: SQL Server Native Client 11.0
  2. Server Name: 192.168.1.47 (IP Address Linux virtual machine)
  3. Authentication: SQL Server Authentication (I have configured the SQL Server authentication to connect to the SQL Server on CentOS)
  4. Username: sa
  5. Password: Specify the sa password
  6. Database: DevStackoverFlow2010

Following is the screenshot:

Select destination SQL database

On the Specify Table Copy or Query screen, you can choose any of the following options

  1. Copy data from tables or views: Choose this option to copy all tables and views with their data from the source SQL database to the SQL destination database.
  2. Write a query to copy the specific data to transfer: Choose this option if you want to copy a specific dataset from one or multiple tables or view from the source database to the destination database. We can write a SQL Query to copy the data between source and destination.

We are copying all tables and data from StackOverFlow2010 to DevStackOverFlow2010, so choose the first option.

Copy data between SQL Server on Windows and CentOS

On the Select Source Tables and Views screen, we can choose all or specific tables and view whose data you want to transfer between the source and destination database server. We are transferring the data of the Stackoverflow2010 database, and it has few tables, so the list of tables and views are listed in the source column of the Tables and Views grid-view. The DevStackoverflow2010 database is empty and does not have any tables, so the destination column of the Tables and Views grid-view will be empty. See the following image.

List of source tables

Now, we want to transfer all tables and data from the Stackoverflow2010 database to the DevStackoverflow2010 database; click on the checkbox at the top of the Tables and Views gridview. When we click on the check box, the wizard automatically generates the definition of the source database table. Click Next.

The destination database

The SQL Server 2019 import-export wizard creates a SQL Server integration services package. Hence, you have an option to save the package on the file system, or you can deploy it in the SQL Server integration service catalog database. On the Save and Run package screen, you have an option to save the SSIS package on the file system or integration service database. We are saving the integration service package to the D:\Migration directory. To do that, select the Save SSIS Package option.

It enables the following actions.

  1. SQL Server: Choose this option if you want to save the package in an integration service catalog.
  2. File system: Choose this option if you want to save the SSIS package on a computer.

Also, we can define the SSIS package protection level. We do not want to use the package protection; therefore, select the “Do not save sensitive data” option from the Package protection level drop-down box. Click Next.

Save SSIS Package

On the Save SSIS Package screen, enter values of the following options.

  1. Name: Enter desired package name.
  2. Description: Describe the SSIS Package.
  3. File Name: Specify the filename and location.

Click on Finish to begin the data transfer.

Save the SSIS package

On the Complete the Wizard screen, you can view the lists of actions that are going to be performed by the wizard.

View the list of actions

The data migration process begins.

SQL database tables are copying

The stackoverflow2010 database is large so it will take some time to finish. Once data has been copied, run the following query to verify that data have been copied. To verify, run the following query.

Query output

Row count of DevStackoverflow2010 database

As you can see, all records of the Badges table have been copied.

Summary

This article explained how to transfer the data of the SQL database from SQL Server on Windows 10 to SQL Server on CentOS. I have explained how we can use SQL Server 2019 import-export wizard to transfer data from source to destination server. This method gives you more control over managing the tables and data. Suppose we are testing a specific module of an application to test the application’s behavior after migrating the database to the Linux operating system. We can use the import-export wizard to migrate the specific tables and views along with the data. The next article will explore the methods to automate database maintenance tasks.

Nisarg Upadhyay
168 Views