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:
A Babelfish-enabled RDS for PostgreSQL instance. See Enable Babelfish for an ApsaraDB RDS for PostgreSQL instance
A Babelfish account on the instance. See Manage Babelfish accounts
An IP address whitelist configured so your client machine can reach the instance. See Configure an IP address whitelist
The instance endpoint and TDS port. See View the endpoints and TDS port
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.
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).
In Object Explorer, right-click the database you want to migrate, then choose Tasks > Generate Scripts.

Work through the Generate Scripts wizard:
Introduction: Click Next.
Choose Objects: Select Script entire database and all database objects, then click Next.

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.
To export DML statements only (data): Set Type of data to script to Data only. 
Summary: Click Next.
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.
For usage instructions, see the Babelfish Compass documentation.
Step 3: Run the modified T-SQL scripts on the Babelfish-enabled instance
Connect to the RDS instance over the TDS port. See Use clients to connect to an ApsaraDB RDS for PostgreSQL instance with Babelfish enabled.
Execute the modified T-SQL statements on the RDS instance.