Request an exact quote
Databases migration path

From Microsoft SQL Server to PostgreSQL

What it takes to move SQL Server to PostgreSQL, the licensing economics, T-SQL conversion, where Babelfish removes the app rewrite, and how to cut over safely.

Effort
High
Est. timeline
~18 wks
PostgreSQL model
Free (optional support)
Open source
Yes
▶ Model your savings in the interactive calculator

SQL Server is licensed per core (with a four-core-per-VM minimum), usually layered with Software Assurance, and its edition ceilings push expensive upgrades as you scale, and it drags Windows Server licensing along with it. PostgreSQL is the most common open-source destination: a mature relational engine with strong SQL support, rich extensions, and no license fee. The data movement is the easy part; the work is T-SQL and application SQL, and that is what this guide walks through.

The economics

SQL Server cost is driven by the cores of the database VM, and the higher-end features live behind Enterprise edition. PostgreSQL removes the license entirely, leaving infrastructure plus optional commercial support (EDB, Percona, Crunchy Data). For most workloads the three-year TCO falls sharply, so the decision hinges on conversion effort, not on whether it saves money.

What converts cleanly, and what doesn’t

Schema and data migrate well. The friction is dialect:

  • T-SQL procedures, functions, and triggers → PL/pgSQL. Simple logic converts; heavy T-SQL (temp tables, MERGE quirks, error handling, table-valued parameters) needs rework.
  • Datatypes. DATETIME/DATETIME2timestamp, MONEYnumeric, UNIQUEIDENTIFIERuuid, NVARCHARtext/varchar, and IDENTITYGENERATED ... AS IDENTITY or sequences.
  • Dialect habits. Bracketed [identifiers], TOP vs LIMIT, ISNULL vs COALESCE, GETDATE() vs now(), the dbo default schema, and case-folding all differ.
  • Application SQL. This is usually the largest hidden cost, every embedded query and ORM mapping that assumed T-SQL has to be validated.

Babelfish: skipping most of the app rewrite

If the application rewrite is the blocker, Babelfish for PostgreSQL is the lever. Babelfish adds a TDS endpoint and a T-SQL dialect layer so existing SQL Server clients and much of their T-SQL connect to PostgreSQL with little or no change. It runs in Amazon Aurora and as the open-source Babelfish for PostgreSQL you can self-host. It won’t cover 100% of T-SQL, but it can turn a rewrite project into a compatibility-gap project, a very different cost.

Tooling

pgloader handles schema-plus-data for straightforward databases in one pass. AWS Schema Conversion Tool (SCT) assesses complexity and converts schema and code, flagging what needs manual work, and pairs with AWS DMS for change-data-capture so the target stays current with low cutover downtime. The open-source sqlserver2pgsql is an alternative schema/converter.

For a small or straightforward database where a maintenance window is acceptable, a single pgloader run is often enough and is the fastest path. For a large database that needs low downtime, lean on SCT for the schema and code conversion and DMS for full-load plus CDC. Whichever you pick, generate an assessment first (an SCT report or a pgloader dry run) and let it, rather than optimism, size the procedural conversion work.

The procedural code that needs hands

The schema and data move well; the friction is dialect and procedural code. Beyond the datatype and habit differences above, watch these:

  • MERGE and temp tables. T-SQL MERGE has quirks that do not map one-to-one to PostgreSQL’s INSERT ... ON CONFLICT, and #temp tables become CREATE TEMP TABLE or CTEs. Review each usage.
  • Error handling. TRY/CATCH and @@ERROR patterns become PL/pgSQL BEGIN ... EXCEPTION blocks, which have different scoping and rollback semantics.
  • Built-in functions. ISNULL becomes COALESCE, GETDATE() becomes now(), TOP becomes LIMIT, and string/date functions differ enough that each needs checking.
  • dbo and schemas. The default dbo schema and cross-database three-part names do not exist in PostgreSQL; plan a schema layout up front.

Application SQL changes

The application SQL is usually the largest hidden cost, and Babelfish is the lever that can shrink it. Without Babelfish, every embedded query, ORM mapping, reporting query, and ETL job that assumed T-SQL has to be validated and often edited: bracketed identifiers, TOP, ISNULL, GETDATE(), and SCOPE_IDENTITY() all change. With Babelfish, much of that T-SQL continues to run against PostgreSQL through the TDS endpoint, so the work becomes finding and fixing the compatibility gaps rather than rewriting everything. Either way, inventory every place SQL is written before you commit to a scope, because the code you cannot see is what slips the schedule.

Sequencing the migration

  1. Assess with SCT (or a pgloader dry run); triage objects by conversion difficulty, and decide Babelfish vs native PostgreSQL.
  2. Provision a primary plus replicas, sized on vCPU, with backups and tuning.
  3. Convert schema, review the action items, load into PostgreSQL.
  4. Migrate data, a bulk load for the rehearsal, then CDC replication to keep the target current.
  5. Convert procedures and application SQL in parallel with data work.
  6. Validate with row counts, checksums/data-diffs, an application regression suite, and query-plan comparisons against the SQL Server baseline.
  7. Cut over in a window: quiesce writes, drain CDC to zero lag, run a final diff, repoint connection strings, smoke-test, and keep SQL Server recoverable through hypercare.

Where the schedule lives or dies

The biggest predictor of a clean cutover is the depth of the parallel-run and validation phase. Replay representative workloads against both databases, compare results and plans, and only promote when documented acceptance criteria, correctness, performance, and failover, are met.

What it comes down to

SQL Server → PostgreSQL reliably cuts licensing cost; the effort is T-SQL and application-SQL conversion plus rigorous validation, not the data movement. Babelfish can remove most of the application rewrite if you accept its compatibility gaps. Model your per-core savings in the calculator above, and treat the figures as illustrative until a support vendor or distributor quotes your environment.

Tooling & automation for this path

pgloader or AWS SCT; or Babelfish for Aurora to keep T-SQL compatibility.

Primary references: official PostgreSQL documentation ↗ and the Microsoft SQL Server documentation ↗ , always verify version-specific behavior against them before you migrate.

Frequently asked questions

When should I use Babelfish instead of a native PostgreSQL conversion?

Reach for Babelfish when the application rewrite, not the database, is the blocker. Babelfish adds a TDS endpoint and a T-SQL dialect layer so existing SQL Server clients and much of their T-SQL connect with little or no change, turning a rewrite project into a compatibility-gap project. It will not cover 100% of T-SQL, so you still test for gaps, but it can remove most of the application-side effort.

How does SQL Server IDENTITY convert to PostgreSQL?

An IDENTITY column typically becomes a GENERATED ... AS IDENTITY column or a sequence with a nextval default. The values migrate fine, but you must reset the sequence high-water mark after the bulk load, or the first new insert collides with an existing key. Also check any code that relied on SCOPE_IDENTITY() or @@IDENTITY, which becomes RETURNING in PostgreSQL.

What T-SQL constructs give pgloader and SCT the most trouble?

The procedural surface, not the schema. Temp tables, the quirks of MERGE, TRY/CATCH error handling, and table-valued parameters need hand rework when converting to PL/pgSQL. Set-based queries usually port with edits, but anything that leans on T-SQL control flow or SQL Server session semantics should be reviewed rather than trusted to the converter.

Do bracketed identifiers and case-folding cause problems moving to PostgreSQL?

Yes, subtly. SQL Server bracketed [identifiers] are usually case-insensitive, while PostgreSQL folds unquoted identifiers to lowercase and treats double-quoted ones as case-sensitive. If your T-SQL mixes casing, you can end up needing quotes everywhere in Postgres. Standardize on lowercase unquoted names during conversion to avoid a permanent quoting tax.

Model your 3-year cost

Pre-filled for Microsoft SQL Server → PostgreSQL; adjust every figure with your own numbers. Estimates are illustrative, not vendor quotes, see our methodology.

Sized at 64 vCPUs, cost is computed on this.
Stay on Microsoft SQL Server (3yr)
$153,600
Move to PostgreSQL (3yr + migration)
$79,680
Projected savings
$73,920 (48%)
Payback period
17.8 mo
Build a decision report from these numbers:

How this is licensed: Oracle and SQL Server license by the vCPUs of the database server VM. Oracle applies a per-core factor and counts ALL vCPUs unless the workload runs on approved hard-partitioned or Oracle-engineered hardware; SQL Server has a 4-vCPU-per-VM minimum. Set $/vCPU to your edition and core factor.

Illustrative, editable figures, not vendor pricing (defaults reviewed May 2026).

Request a vendor-accurate PostgreSQL quote

A guided builder that turns your estimates into a requirements report (RFQ) you can send to a vendor, partner, or distributor for a binding quote, then feed the real prices back into the calculator above. How our estimates work.

  1. 1Size it
  2. 2Requirements
  3. 3Your details
  4. 4Channels & export

How big is your Microsoft SQL Server estate?

Count the OS/database server VMs and their typical vCPU allocation. Licensing usually counts all vCPUs on each VM. Not sure? Enter rough numbers, the distributor confirms exact counts later.

64 vCPUs
Default mid-size assumption (64 vCPUs)