Skip to content
migration.tools
SQL Server to PostgreSQL

SQL Server to PostgreSQL converter

Convert a SQL Server script generated by SSMS into PostgreSQL. Bracketed identifiers, IDENTITY columns, NVARCHAR and GO batches are all translated.

Going the other way? PostgreSQL to SQL Server

Options

SQL Server SQL

PostgreSQL SQL

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Export your database (SSMS → Tasks → Generate Scripts) and paste the SQL, or drop the .sql file.
  2. 2Read the review notes under the output — they list everything that needs a human decision.
  3. 3Download the PostgreSQL script and run it against a staging database first.

What changes between SQL Server and PostgreSQL

[bracketed] identifiers become double-quoted, the dbo. schema prefix is removed and GO batch separators become ordinary statement ends.

IDENTITY(1,1) becomes GENERATED BY DEFAULT AS IDENTITY; BIT becomes BOOLEAN with TRUE/FALSE data; NVARCHAR(MAX) becomes TEXT; DATETIME2 becomes TIMESTAMP; UNIQUEIDENTIFIER becomes UUID; MONEY becomes NUMERIC(19,4).

Defaults lose their double parentheses — ((0)) becomes 0 — and getdate() and newid() become CURRENT_TIMESTAMP and gen_random_uuid(). In queries, TOP n becomes LIMIT n and ISNULL() becomes COALESCE().

SET ANSI_NULLS, SET IDENTITY_INSERT, WITH (PAD_INDEX…) and ON [PRIMARY] clauses are dropped.

What to check before you run it

Run the converted script against an empty staging database first, inside a transaction if the target supports transactional DDL. The review notes under the output list every statement that was dropped, every type with no direct equivalent and every clause that needs a manual decision.

Views, triggers, stored procedures and functions are passed through unchanged and flagged. Their bodies are written in SQL Server's procedural language and need a human rewrite for PostgreSQL.

After loading, compare row counts table by table. For a deeper check, export a table from both databases and run the two files through the CSV compare tool.

Questions

Does it convert T-SQL stored procedures?

No. Procedures, functions and triggers are passed through unchanged and flagged, because T-SQL and PL/pgSQL differ too much for a mechanical translation to be trustworthy.