How to use it
- 1Export your database (pg_dump) and paste the SQL, or drop the .sql file.
- 2Read the review notes under the output — they list everything that needs a human decision.
- 3Download the SQL Server script and run it against a staging database first.
What changes between PostgreSQL and SQL Server
SERIAL and identity columns become IDENTITY(1,1), with SET IDENTITY_INSERT around the data. COPY blocks become INSERT statements in batches of 1,000.
BOOLEAN becomes BIT with 1/0 values, TEXT and JSONB become NVARCHAR(MAX), TIMESTAMPTZ becomes DATETIMEOFFSET, UUID becomes UNIQUEIDENTIFIER and BYTEA becomes VARBINARY(MAX).
gen_random_uuid() becomes NEWID(), ::casts are removed, and ON DELETE RESTRICT becomes NO ACTION.
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 PostgreSQL's procedural language and need a human rewrite for SQL Server.
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
Are IF NOT EXISTS clauses kept?
SQL Server doesn't support CREATE TABLE IF NOT EXISTS, so it is removed. DROP TABLE IF EXISTS is kept, since SQL Server 2016 and later accept it.