This topic describes how to migrate the data of a SQL Server database to a database on an ApsaraDB RDS for PostgreSQL instance for which Babelfish is enabled. Babelfish features compatibility, which enables you to complete the migration in an efficient manner without the need to rewrite a large amount of code. This facilitates migration and reduces resource consumption.
Prerequisites
An RDS instance for which Babelfish is enabled is created. For more information, see Enable Babelfish for an ApsaraDB RDS for PostgreSQL instance.
A Babelfish account is created. For more information, see Manage Babelfish accounts.
A whitelist is configured to allow the server on which the client resides to access the RDS instance. For more information, see Configure an IP address whitelist.
The endpoints and Tabular Data Stream (TDS) port of the RDS instance are obtained. For more information, see View the endpoints and TDS port.
Procedure
Export the table objects and data of the SQL Server database.
Connect to the SQL Server database by using SQL Server Management Studio (SSMS). For more information, see Quickstart: Connect and query a SQL Server instance using SQL Server Management Studio (SSMS).
In the left-side navigation pane of Object Explorer, right-click the SQL Server database that you want to migrate. Then, choose .
In the Generate Scripts configuration wizard, configure the parameters and export the script to a
.sql
file.Click Next in the Introduction step.
In the Choose Objects step, select Script entire database and all database objects and click Next.
In the Set Scripting Options step, select Save as script file and configure the File name parameter. Then, click Next.
If you want to export the DDL statements of the SQL Server database, perform the following operations: In the Set Scripting Options step, click Advanced. In the Advanced Scripting Options dialog box, configure the parameters based on the following figure:
If you want to export the data manipulation language (DML) statements of the SQL Server database, perform the following operations: In the Set Scripting Options step, click Advanced. In the Advanced Scripting Options dialog box, set Type of data to script to Data only.
In the Summary step, click Next.
In the Save Scripts step, click Confirm.
After the configuration, you can obtain the
.sql
file from the path that you specified in the Set Scripting Options step.
Run Babelfish Compass to check how Babelfish supports T-SQL statements and make required modifications based on the results.
NoteFor more information about Babelfish Compass, see Babelfish Compass official documentation.
Execute the modified T-SQL statements on the RDS instance for which Babelfish is enabled.
Connect to the RDS instance over the TDS port. For more information, see Use clients to establish connections.
Execute the modified T-SQL statements on the RDS instance.
References
For more information about Babelfish Compass, see Babelfish Compass official documentation.
For more information about how to connect to the TDS port of the RDS instance for which Babelfish is enabled, see Client connection example.
The endpoints and TDS port of the RDS instance are obtained. For more information, see View the endpoints and TDS port.