All Products
Search
Document Center

ApsaraDB RDS:Migrate the data of a SQL Server database to a database on an ApsaraDB RDS for PostgreSQL instance with Babelfish enabled

Last Updated:Mar 28, 2026

Migrating from SQL Server to PostgreSQL typically requires rewriting application code to replace T-SQL with PostgreSQL-compatible syntax. Babelfish for ApsaraDB RDS for PostgreSQL eliminates this barrier by accepting T-SQL connections over the Tabular Data Stream (TDS) port, so your SQL Server application can connect to the target instance without code changes. This guide walks you through exporting your SQL Server schema and data, checking T-SQL compatibility with Babelfish Compass, and running the scripts on the target instance.

Prerequisites

Before you begin, ensure that you have:

Migrate a SQL Server database

Step 1: Export the schema and data from SQL Server

Use SQL Server Management Studio (SSMS) to generate .sql scripts from the source database.

  1. Connect to the SQL Server database in SSMS. For connection instructions, see Quickstart: Connect and query a SQL Server instance using SQL Server Management Studio (SSMS).

  2. In Object Explorer, right-click the database you want to migrate, then choose Tasks > Generate Scripts.

    Generate scripts from the Tasks menu

  3. Work through the Generate Scripts wizard:

    1. Introduction: Click Next.

    2. Choose Objects: Select Script entire database and all database objects, then click Next. 选择对象

    3. Set Scripting Options: Select Save as script file, set a File name, then click Next. 设置脚本编写选项 To control what the script exports, click Advanced and set the following options: To export DDL statements only (schema): Configure the options as shown below. DDL导出 To export DML statements only (data): Set Type of data to script to Data only. DML导出

    4. Summary: Click Next.

    5. Save Scripts: Click Confirm.

The .sql file is saved to the path you specified in the Set Scripting Options step.

Step 2: Check T-SQL compatibility with Babelfish Compass

Run Babelfish Compass against the exported .sql file to identify any T-SQL statements that Babelfish does not support. Review the compatibility report and modify your scripts before running them on the target instance.

Note

For usage instructions, see the Babelfish Compass documentation.

Step 3: Run the modified T-SQL scripts on the Babelfish-enabled instance

  1. Connect to the RDS instance over the TDS port. See Use clients to connect to an ApsaraDB RDS for PostgreSQL instance with Babelfish enabled.

  2. Execute the modified T-SQL statements on the RDS instance.

References