PostgreSQL to Microsoft SQL Server Migration

SQLines tools can help you convert database schema (DDL), views, stored procedures, functions, triggers, queries and SQL scripts from PostgreSQL (Postgres) to Microsoft SQL Server (MSSQL, MS SQL), Azure SQL, Azure Synapse and Fabric.

Databases:

  • PostgreSQL 16.x, 15.x, 14.x, 13.x, 12.x, 11.x, 10.x and 9.x
  • Microsoft SQL Server 2022, 2019, 2017, 2016, 2014, 2012, 2008 and 2005

Migration Reference

Built-in SQL Functions

Converting string functions:

PostgreSQL SQL Server
1 RPAD(string, len, pad) Pad the right-side of string LEFT(string + REPLICATE(pad, len), len)
2 TRIM(string) Remove leading and trailing blanks from string TRIM(string) Since SQL Server 2017
RTRIM(LTRIM(string))

Converting datetime functions:

PostgreSQL SQL Server
1 TO_TIMESTAMP(string, format) Convert string to timestamp CONVERT(DATETIME, string, style)

CREATE TABLE Statement

Converting CREATE TABLE statement keywords and clauses.

For Synapse:

PostgreSQL Synapse
1 PRIMARY KEY (col) Primary key constraint PRIMARY KEY NONCLUSTERED (col) NOT ENFORCED
2 UNIQUE (col) Unique constraint UNIQUE (col) NOT ENFORCED