SQL translator › PostgreSQL → T-SQL

PostgreSQL to SQL Server translator

Postgres people type ::int and ||. SQL Server types CAST and CONCAT.

Usual swaps

PostgreSQLSQL Server
LIMIT / OFFSETOFFSET n ROWS FETCH NEXT m ROWS ONLY
ILIKELIKE on a CI collation
a::typeCAST(a AS type)
a || bCONCAT(a, b)
DATE_TRUNC('month', d)DATEFROMPARTS(YEAR(d), MONTH(d), 1)
FILTER (WHERE …)SUM(CASE WHEN … THEN x END)
BOOLEAN / TRUEbit / 1
SERIALINT IDENTITY(1,1)
GENERATE_SERIESrecursive CTE or a tally

RETURNING is OUTPUT INSERTED. ILIKE on a CS column needs a CI collation, not LOWER(col).

Then write it on a ticket

Monday is free. A colleague asks, you type, we mark it.

Clock in free