Migrate SQL Server to PostgreSQL
Certified — live-tested pathThe converter maps 21 SQL Server column types to PostgreSQL. Each lands in the same kind of PostgreSQL type; the table below shows the exact spelling and any limit that differs. DBShifts converts the schema, copies the rows in parallel batches and checks the result with row counts and checksums.
Free tier · no credit card
SQL Server vs PostgreSQL
SQL Server
Microsoft's enterprise relational database.
PostgreSQL
the most advanced open-source relational database.
SQL Server to PostgreSQL data type mapping
Pulled directly from DBShifts's own conversion rules — not a general reference table, this is what actually runs.
| SQL Server | PostgreSQL |
|---|---|
| INT | INTEGER |
| BIGINT | BIGINT |
| SMALLINT | SMALLINT |
| TINYINT | SMALLINT |
| BIT | BOOLEAN |
| DECIMAL(10,2) | NUMERIC(10,2) |
| MONEY | NUMERIC |
| FLOAT | DOUBLE PRECISION |
| REAL | REAL |
| VARCHAR(255) | VARCHAR(255) |
| NVARCHAR(255) | VARCHAR(255) |
| NVARCHAR(MAX) | TEXT |
| TEXT | TEXT |
| CHAR(10) | CHAR(10) |
| DATE | DATE |
| DATETIME | TIMESTAMP |
| DATETIME2 | TIMESTAMP |
| DATETIMEOFFSET | TIMESTAMPTZ |
| TIME | TIME |
| VARBINARY(MAX) | BYTEA |
| UNIQUEIDENTIFIER | UUID |
Example: SQL Server to PostgreSQL schema conversion
SQL Server
CREATE TABLE orders ( id INT IDENTITY(1,1) PRIMARY KEY, customer_id INT NOT NULL, total DECIMAL(10,2) NOT NULL, is_gift BIT NOT NULL DEFAULT 0, notes NVARCHAR(MAX), reference UNIQUEIDENTIFIER, placed_at DATETIME2 NOT NULL );
PostgreSQL
CREATE TABLE IF NOT EXISTS "orders" (
"id" SERIAL,
"customer_id" INTEGER NOT NULL,
"total" NUMERIC(10,2) NOT NULL,
"is_gift" BOOLEAN NOT NULL DEFAULT FALSE,
"notes" TEXT,
"reference" UUID,
"placed_at" TIMESTAMP NOT NULL,
PRIMARY KEY ("id")
);Case-insensitive in SQL Server, case-sensitive in PostgreSQL
SQL Server's usual default collation, SQL_Latin1_General_CP1_CI_AS, compares text without regard to case. PostgreSQL compares it exactly. After the move, WHERE email = 'Bob@example.com' stops finding bob@example.com, and a unique index that let SQL Server hold only one of the two will happily hold both.
There are three fixes, in rising order of effort: query lower(email) against an expression index on lower(email); use the citext extension for the columns where case should not matter; or define a nondeterministic ICU collation, available since PostgreSQL 12. Pick per column, because most text columns do not need it and the ones that do are usually obvious: emails, usernames, codes.
BIT, TOP and SCOPE_IDENTITY()
BIT becomes BOOLEAN, which PostgreSQL will not compare with a number: WHERE is_gift = 1 fails with operator does not exist. With the target schema connected, the rewriter changes = 1 and = 0 to TRUE and FALSE on exactly those columns. TOP n becomes LIMIT n and square-bracket identifiers become double-quoted; TOP … PERCENT has no direct equivalent and is reported for a hand rewrite.
@@IDENTITY and SCOPE_IDENTITY() are SQL Server's ways of reading back a new id. The PostgreSQL form returns it from the statement itself, INSERT … RETURNING id, which is also immune to the trigger problems @@IDENTITY has. The rewriter flags both calls, because the fix changes how the application reads the result.
DATETIMEOFFSET keeps the instant, not the offset
DATETIMEOFFSET maps to TIMESTAMPTZ, and the name suggests the offset comes along. It does not: PostgreSQL's timestamptz normalises every value to UTC and displays it in the session's time zone. The instant survives exactly. The +05:30 the row was written with does not. If that offset is information, a customer's local time for example, store it in a column of its own.
DATETIME2(7) has 100-nanosecond precision and PostgreSQL stops at microseconds, so the seventh fractional digit is dropped. That rarely matters, except where timestamps break ties in an ORDER BY or form part of a unique key.
SQL Server → PostgreSQL conversion notes
Engine-specific rules baked into the conversion and transfer pipeline — verified by live certification of this exact pair.
- TINYINT is unsigned (0–255) in SQL Server — DBShifts widens it on signed targets so 128–255 don't clip.
- UNIQUEIDENTIFIER, DATETIMEOFFSET, MONEY and NVARCHAR(MAX) all have explicit conversion rules per target.
- Wrapped defaults like ((1)) and (N'foo') are unwrapped to portable literals.
- Bulk loads use sequence reseeding (setval to MAX) so SERIAL columns keep working after migration.
- ENUMs from MySQL become native CREATE TYPE … AS ENUM — validation semantics preserved.
- Foreign keys and indexes are applied after data load for dramatically faster transfers.
Frequently asked questions
Is SQL Server to PostgreSQL migration production-ready in DBShifts?
Yes. SQL Server to PostgreSQL is a certified pair: it passes the live certification suite on real SQL Server and PostgreSQL servers, which checks schema fidelity, row counts, type-aware checksums and paging across batches.
What happens to SQL Server types that PostgreSQL doesn't have?
None of the common ones are missing: every type in the table lands in the same kind of PostgreSQL type. What still differs is limits and defaults, which the notes beside each row cover.
Can I keep SQL Server and PostgreSQL in sync after the initial migration?
Yes, until you cut over. DBShifts reads SQL Server Change Tracking, which has to be enabled on the database and on each table. With zero-downtime mode on, the tracking version is captured before the first row is copied.
Which SQL Server data types need a second look when moving to PostgreSQL?
The table above carries a note on 4 of them: MONEY (NUMERIC), FLOAT (DOUBLE PRECISION), DATETIMEOFFSET (TIMESTAMPTZ), UNIQUEIDENTIFIER (UUID). Analysis flags the same columns on your own schema before any data moves.
Go deeper
How We Live-Certified All 49 Migration Paths
The certification harness behind this page's claims.
Zero-Downtime Migration with Change Data Capture
Snapshot, stream the changes made meanwhile, and stay in sync until cutover.
Reference
Compared with other tools
Ready to move SQL Server to PostgreSQL?
Set up in under two minutes. Validation and rollback included.
Start Free Migration