Home / Databases / SQL Server

DatabasesHow-toAdvanced

Refactor SQL Server to Aurora PostgreSQL with Babelfish: assess, migrate and run

Use Babelfish for Aurora PostgreSQL to move SQL Server applications off SQL Server licences with fewer code changes. Covers Babelfish Compass assessment, migration modes, creating the cluster, moving schema and data, connecting apps over TDS, and testing gaps.

Deepak Bhardwaj3 min read

Applies toSQL Server 2008+ applications; Amazon Aurora PostgreSQL with Babelfish (check the supported feature list for your version)

How Babelfish works

Aurora PostgreSQL gets a TDS endpoint (port 1433) that understands the SQL Server wire protocol and much of T-SQL. Apps can keep using SQL Server drivers and many queries unchanged. Data is stored in PostgreSQL, and you can also query it with PostgreSQL tools on port 5432.

It's not 100% SQL Server: some features are unsupported or behave differently. Assessment decides whether it fits.

1. Assess with Babelfish Compass

  1. Script the database objects (SSMS → Generate Scripts, include all object types).
  2. Run Compass against the DDL:
BabelfishCompass.bat SalesReport C:\ddl\Sales.sql
  1. Review the HTML report: supported, review semantics, not supported (with counts per feature).

Rough guide: if unsupported items are few and in non-critical code, Babelfish is a good fit. Heavy CLR, Service Broker, cross-server linked queries or many unsupported built-ins → choose RDS/MI or a full PostgreSQL rewrite.

2. Choose the migration mode (at cluster creation — can't change later)

Mode Meaning
single-db One T-SQL database; its schemas map to PostgreSQL schemas with the same names
multi-db Several T-SQL databases; schemas are named <db>_<schema> in PostgreSQL

Pick multi-db if the app uses several databases (cross-database queries within the cluster are supported).

3. Create the cluster

Create an Aurora PostgreSQL cluster with a parameter group where rds.babelfish_status = on and babelfishpg_tsql.migration_mode set, or tick Turn on Babelfish in the console. Note the TDS endpoint (<cluster>.cluster-xxxx.<region>.rds.amazonaws.com,1433).

4. Move the schema

  1. Run the generated DDL through SSMS or sqlcmd against the TDS endpoint.
  2. Fix objects that fail (Compass report tells you which), or rewrite them.
  3. Create logins and users through the TDS endpoint with T-SQL (CREATE LOGIN, CREATE USER).

5. Move the data

Method Use
AWS DMS (target endpoint: Babelfish) Full load + CDC for minimal downtime
bcp out from SQL Server, bcp in through the TDS endpoint Simple, offline
SSIS / ADF Existing ETL tooling

6. Connect the app

Change only the server name (and credentials) in the connection string; keep the SQL Server driver:

Server=sales-babelfish.cluster-abc.ap-south-1.rds.amazonaws.com,1433;Database=Sales;User Id=app;Password=...;Encrypt=True;

7. Test thoroughly

  • Run full regression tests: Babelfish may return different results for things like collation behaviour, error messages, certain date functions, or transaction semantics.
  • Performance test: query plans are PostgreSQL's; some T-SQL patterns need indexes or rewrites.
  • Check tools: SSMS works for many tasks against the TDS endpoint; some designer features don't.

8. Operate

Aurora features apply: storage auto-scaling, up to 15 readers, Multi-AZ, Global Database, backups and PITR. Monitor with Performance Insights / CloudWatch Database Insights.

Tip

Start with an app you own the code for. Babelfish fits best when developers can fix the handful of incompatibilities; vendor packages often aren't certified on it.