SQL Server to PostgreSQL Converter
Paste T-SQL from SQL Server and get PostgreSQL-compatible SQL back. The converter rewrites bracketed identifiers, IDENTITY columns, NVARCHAR/BIT/MONEY/DATETIME2 types, TOP n, ISNULL, GETDATE, DATEADD, CROSS APPLY and OFFSET/FETCH paging, strips GO, NOLOCK, CLUSTERED and ON [PRIMARY] noise, and lists every construct that still needs a human decision. Best-effort and browser-only: nothing is uploaded.
Do more than sql server to postgresql converter — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Paste a SQL Server CREATE TABLE script, index definition or SELECT query.
- Click Convert to PostgreSQL.
- Read the warnings, fix the flagged parts, then run the result in psql or Chat2DB.
Frequently asked questions
What does the converter translate automatically?
Bracketed [identifiers] to lower-case or double-quoted names, the dbo. schema prefix, IDENTITY(1,1) to GENERATED ALWAYS AS IDENTITY, NVARCHAR/NCHAR/NVARCHAR(MAX), BIT, TINYINT, MONEY, DATETIME/DATETIME2/DATETIMEOFFSET, UNIQUEIDENTIFIER and VARBINARY types, TOP n to LIMIT n, OFFSET/FETCH paging, ISNULL, LEN, GETDATE, GETUTCDATE, NEWID, IIF, CHARINDEX, simple CONVERT and DATEADD/DATEDIFF(day), CROSS/OUTER APPLY, plus removal of GO, SET NOCOUNT, WITH (NOLOCK), CLUSTERED, index WITH options and ON [PRIMARY].
What still needs manual work after converting?
Anything procedural: @variables, IF/BEGIN/END, stored procedures, PRINT, SCOPE_IDENTITY and @@ROWCOUNT must be rewritten in plpgsql. DATEDIFF with non-day units, FORMAT(), STUFF + FOR XML PATH, FOR JSON, MERGE edge cases, ROWVERSION columns and case-insensitive collations are flagged with a suggested PostgreSQL replacement rather than changed silently.
How do I move the data, not just the schema?
After the DDL runs in PostgreSQL, copy rows with a migration tool. Chat2DB, a free AI-powered SQL client for Windows, macOS and Linux, connects to both SQL Server and PostgreSQL and can migrate tables between them visually; its AI assistant also rewrites the T-SQL queries this tool flags.
