---
title: "Migrate PostgreSQL to SQL Server in your browser"
description: "Migrate a PostgreSQL database to SQL Server: convert a pg_dump file into a script with the same tables, keys and data, and a report of every change."
canonical: https://intosql.com/postgresql-to-sql-server
last_updated: 2026-10-15
---

# Migrate PostgreSQL to SQL Server in your browser

Drop a plain dump from pg_dump or pg_dumpall, as .sql or .sql.gz, and download a script for SQL Server with the same tables, keys, indexes and data. Every value SQL Server can't hold as it is, and every object it doesn't carry, is listed in the report.

[PostgreSQL to SQL Server migration guide](https://intosql.com/docs/migrations/postgresql-to-sql-server)

[PostgreSQL to SQL Server data types](https://intosql.com/docs/types/postgresql-to-sql-server)

## What changes from PostgreSQL to SQL Server

Each row is a rule the converter applies, with the report line it writes when the rule changes something in your data.

| In PostgreSQL | In SQL Server | Report line |
| --- | --- | --- |
| boolean | bit |  |
| varchar(n), char(n), text | nvarchar(n); text as nvarchar(max), or nvarchar(450) when a key uses it and every value fits |  |
| text comparison | exact (Latin1_General_100_BIN2); citext ignoring case (Latin1_General_100_CI_AS_SC) |  |
| numeric(p,s) past 38 digits; numeric without a precision | nvarchar; decimal(p,s) fitted to the values when they fit 38 digits | `decimal_as_text` |
| money | decimal(19,2) | `type_replaced` |
| interval | nvarchar(100) with PostgreSQL's text | `type_replaced` |
| arrays (integer[], text[]...) | nvarchar(max) with a JSON array | `type_replaced` |
| ranges, geometric types, tsvector, xml, hstore, PostGIS, composite and extension types | nvarchar(max) with PostgreSQL's text | `type_replaced` |
| json, jsonb | nvarchar(max) |  |
| timestamp | datetime2 |  |
| timestamp with time zone | datetimeoffset in UTC |  |
| time with 24:00:00 in it | nvarchar(17) | `time_as_interval` |
| infinity, -infinity and BC dates | NULL | `date_out_of_range` |
| NaN and Infinity in numeric, real and double precision | NULL | `invalid_value_null` |
| NOT NULL columns with values that become NULL | NOT NULL dropped | `not_null_relaxed` |
| enum types | nvarchar with a CHECK of its labels |  |
| enum columns holding values outside their labels | nvarchar without a check | `enum_check_skipped` |
| uuid, inet, cidr, macaddr | uniqueidentifier; addresses as nvarchar |  |
| bytea | varbinary(max) |  |
| bit(n), bit varying | bit for one bit; bigint up to 63 bits; text digits beyond |  |
| oid, xid, cid | bigint with a CHECK that it isn't negative |  |
| serial, identity | IDENTITY, continuing after the highest id |  |
| a second serial or identity column in a table | a plain integer | `counter_dropped` |
| sequences not owned by a column | CREATE SEQUENCE ... AS bigint, at its next value |  |
| generated columns | computed columns, PERSISTED when the source stores them |  |
| generated columns with functions SQL Server lacks | a plain column with the values | `generated_not_translated` |
| defaults with functions SQL Server lacks, and defaults from a sequence | no default | `default_not_translated` |
| CHECK constraints | translated, inline in CREATE TABLE |  |
| CHECK constraints with functions SQL Server lacks | not created | `check_skipped` |
| CHECK ... NOT VALID | not created | `check_not_valid` |
| gin, gist, brin and hash indexes, partial and expression indexes, and indexes on text that doesn't fit a key | not created | `index_skipped` |
| foreign keys | after the data WITH NOCHECK, then checked with a warning on orphans |  |
| ON DELETE or ON UPDATE that cascades in a cycle or along a second path | NO ACTION | `foreign_key_action_dropped` |
| foreign keys to tables the dump doesn't create | not created | `foreign_key_skipped` |
| partitioned tables | one table with every partition's rows | `partitions_dropped` |
| views, functions, procedures, triggers, rules, policies, extensions and types | listed in the report | `not_converted_objects` |
| dumps without CREATE TABLE (--data-only) | types read from the values | `no_schema` |
| expressions in INSERT values | NULL | `expression_value` |
| types IntoSQL doesn't know | nvarchar(max) | `unknown_type` |
| text that isn't valid in its encoding | the bad bytes as the replacement character | `invalid_utf8_replaced` |
| text decoded twice (Ã±) | copied as it is | `mojibake_suspected` |

## Load the script into SQL Server

The script creates the tables, copies the rows, then adds keys, indexes and foreign keys, so it loads fast and stops at the first error.

```shell
sqlcmd -b -f 65001 -S localhost -d mydb -i postgresql.sql_server.sql
```

Foreign keys are added WITH NOCHECK and then checked. If a row points to a row that doesn't exist, the script says which constraint and leaves it unchecked, instead of failing half way.

For a large dump, run sqlcmd on the same machine as the server. Each batch of up to 1000 rows commits on its own, so the transaction log stays small.

## Dump PostgreSQL for the best result

The converter reads what the dump holds. These options keep more of your data in it:

- --format=plain, pg_dump's default, writes SQL. A custom or directory archive (-Fc, -Fd) becomes SQL with pg_restore -f dump.sql, without a database server.
- --no-owner --no-privileges leave out roles and grants, which the converter skips anyway, so the dump is smaller.
- pg_dumpall dumps every database in one file; each one's tables are named after it, so nothing collides.

## What isn't converted

Views, materialized views, functions, procedures, triggers, rules, row security policies, extensions and types are written in PostgreSQL's own language. They are listed in the report by name, never dropped silently, so you can rewrite them for SQL Server.

## Questions about PostgreSQL to SQL Server

### Is my dump uploaded?

No. The converter runs in your browser and reads the dump from your disk in pieces, so it never leaves your computer. The desktop app and the command line convert on your computer too.

### How large can the dump be?

The converter never holds the whole dump in memory: it reads the file twice, by ranges, and writes the script as it goes. Multi-gigabyte dumps convert in the browser, in the desktop app and with the command line.

### Does it read pg_dump -Fc archives?

Not directly: a custom archive is a binary format. pg_restore -f dump.sql dump.backup turns it into the plain SQL the converter reads, without connecting to a server. The converter says so when it gets an archive.

### Which PostgreSQL versions can the dump come from?

Dumps written by pg_dump and pg_dumpall from PostgreSQL 10 on, with COPY or INSERT rows. Every test dump comes from PostgreSQL 13 and 18 and is compared with its source cell by cell.

### Are serial and identity values kept?

Yes. Each table's serial or identity column becomes an IDENTITY column, every row keeps its id, and the next id continues after the highest one. SQL Server counts one column per table, so any other keeps its values without a counter.

### What happens to arrays, enums and other PostgreSQL types?

Arrays become JSON arrays, booleans bit, uuid uniqueidentifier, and timestamps with a time zone datetimeoffset. Text compares exactly, as in PostgreSQL, and citext ignoring case. Ranges, geometric types and composite types keep PostgreSQL's text.

### What about functions, triggers and views?

They are listed in the report by name and not converted, because each database writes them in its own language.

### Which SQL Server versions does the script load on?

SQL Server 2017 to 2025. The same script loads on each of them, stopping at the first error if anything goes wrong.

## From PostgreSQL

- [PostgreSQL to PostgreSQL](https://intosql.com/postgresql-to-postgresql)
- [PostgreSQL to MySQL](https://intosql.com/postgresql-to-mysql)
- [PostgreSQL to MariaDB](https://intosql.com/postgresql-to-mariadb)
- [PostgreSQL to SQLite](https://intosql.com/postgresql-to-sqlite)
- [PostgreSQL to Oracle](https://intosql.com/postgresql-to-oracle)

## Into SQL Server

- [MySQL to SQL Server](https://intosql.com/mysql-to-sql-server)
- [MariaDB to SQL Server](https://intosql.com/mariadb-to-sql-server)
- [SQL Server to SQL Server](https://intosql.com/sql-server-to-sql-server)
- [SQLite to SQL Server](https://intosql.com/sqlite-to-sql-server)
- [Oracle to SQL Server](https://intosql.com/oracle-to-sql-server)

## Guide and every pair

- [SQL Server to PostgreSQL](https://intosql.com/sql-server-to-postgresql)
- [PostgreSQL to SQL Server migration guide](https://intosql.com/docs/migrations/postgresql-to-sql-server)
- [PostgreSQL to SQL Server data types](https://intosql.com/docs/types/postgresql-to-sql-server)
- [Every database pair](https://intosql.com/database-migration)
