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

# Migrate SQL Server to PostgreSQL in your browser

Drop the script SSMS's Generate Scripts writes with schema and data, as .sql or .sql.gz, UTF-16 or UTF-8, and download a script for PostgreSQL with the same tables, keys, indexes and data. Every value PostgreSQL can't hold as it is, and every object it doesn't carry, is listed in the report.

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

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

## What changes from SQL Server to PostgreSQL

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

| In SQL Server | In PostgreSQL | Report line |
| --- | --- | --- |
| bit | boolean |  |
| tinyint | smallint with a CHECK that it isn't negative | `unsigned_widened` |
| char(n), varchar(n), nchar(n), nvarchar(n), varchar(max), text | varchar(n) and text |  |
| decimal(p,s), money, smallmoney | numeric(p,s); money as numeric(19,4) |  |
| datetime, datetime2, smalldatetime | timestamp(p) |  |
| datetime2(7), time(7) and datetimeoffset(7) | six digits of a second, the seventh cut | `fraction_cut` |
| datetimeoffset | timestamptz, the same instants |  |
| time | time(p) |  |
| json (SQL Server 2025) | jsonb |  |
| uniqueidentifier | uuid |  |
| binary, varbinary, image | bytea |  |
| geometry, geography | bytea with SQL Server's own bytes | `spatial_as_native` |
| rowversion, timestamp | bytea, empty | `rowversion_empty` |
| sql_variant, hierarchyid, vector | text | `type_replaced` |
| collations that ignore case (_CI_) | exact comparison | `case_insensitive_collation` |
| IDENTITY | GENERATED BY DEFAULT AS IDENTITY, continuing after the highest id |  |
| CREATE SEQUENCE | CREATE SEQUENCE with the same options |  |
| computed columns | generated columns, STORED | `virtual_as_stored` |
| computed columns with functions PostgreSQL lacks | a plain column | `generated_not_translated` |
| defaults with functions PostgreSQL lacks, and NEXT VALUE FOR | no default | `default_not_translated` |
| CHECK constraints | translated |  |
| CHECK constraints with functions PostgreSQL lacks | not created | `check_skipped` |
| CHECK constraints added WITH NOCHECK or disabled | not created | `check_not_enforced` |
| filtered and columnstore indexes | not created | `index_skipped` |
| foreign keys | foreign keys, after the rows |  |
| foreign keys to tables the dump doesn't create | not created | `foreign_key_skipped` |
| tables on a partition scheme | one table with every partition's rows | `partitions_dropped` |
| temporal tables (SYSTEM_VERSIONING) | two tables: the current rows and the history | `system_versioning_dropped` |
| NOT NULL columns with values that become NULL | NOT NULL dropped | `not_null_relaxed` |
| views, functions, procedures, triggers, synonyms, types and partition functions | listed in the report | `not_converted_objects` |
| scripts without CREATE TABLE (data only) | types read from the values | `no_schema` |
| expressions in INSERT values | NULL | `expression_value` |
| types IntoSQL doesn't know | text | `unknown_type` |
| dates that aren't valid | NULL | `date_out_of_range` |
| NUL characters in text | removed | `nul_removed` |
| 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 PostgreSQL

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
psql -v ON_ERROR_STOP=1 -d mydb -f sql_server.postgresql.sql
```

Foreign keys are added as NOT VALID and then validated. If a row points to a row that doesn't exist, the script tells you which constraint, instead of failing half way.

For a large dump, create the database first and run the script with psql from the same machine as the server.

IntoSQL Pro loads the file straight into PostgreSQL from the desktop app or the command line, without writing a script.

## Dump SQL Server for the best result

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

- In SSMS, right-click the database, Tasks, Generate Scripts, and pick the tables. dbatools, mssql-scripter and other tools built on the same library write the same script.
- Under Advanced, set Types of data to script to Schema and data. A script of the schema alone has tables without rows.
- Save it as Unicode, SSMS's default, or as UTF-8: both are read the same way, and gzip works too.

## What isn't converted

Views, functions, procedures, triggers, synonyms, rules and security policies are written in T-SQL. They are listed in the report by name, never dropped silently, so you can rewrite them for PostgreSQL.

## Questions about SQL Server to PostgreSQL

### 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 the UTF-16 file SSMS saves?

Yes. SSMS saves scripts as UTF-16 by default, and the converter reads UTF-16 and UTF-8 alike, gzipped or not, with GO between batches.

### Which SQL Server versions can the script come from?

Scripts that SSMS, dbatools or mssql-scripter write from SQL Server 2017 on. Every test script comes from SQL Server 2017, 2022 and 2025 and is compared with its source cell by cell.

### Are IDENTITY values kept?

Yes. IDENTITY columns become identity columns, every row keeps its id, and the next id continues after the highest one. Sequences are created with the same options.

### What happens to money, datetimeoffset and other SQL Server types?

bit becomes boolean, money numeric(19,4), uniqueidentifier uuid, xml xml, and datetimeoffset timestamptz. datetime2 keeps six digits of a second, the seventh cut. Columns that ignored case compare exactly, and the report says which ones.

### What about procedures, triggers and views?

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

### Which PostgreSQL versions does the script load on?

PostgreSQL 13 to 18. The same script loads on each of them, stopping at the first error if anything goes wrong.

## From SQL Server

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

## Into PostgreSQL

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

## Guide and every pair

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