SQL translator › PostgreSQL → T-SQL
PostgreSQL to SQL Server translator
Postgres people type ::int and ||. SQL Server types CAST and CONCAT.
Usual swaps
| PostgreSQL | SQL Server |
|---|---|
| LIMIT / OFFSET | OFFSET n ROWS FETCH NEXT m ROWS ONLY |
| ILIKE | LIKE on a CI collation |
| a::type | CAST(a AS type) |
| a || b | CONCAT(a, b) |
| DATE_TRUNC('month', d) | DATEFROMPARTS(YEAR(d), MONTH(d), 1) |
| FILTER (WHERE …) | SUM(CASE WHEN … THEN x END) |
| BOOLEAN / TRUE | bit / 1 |
| SERIAL | INT IDENTITY(1,1) |
| GENERATE_SERIES | recursive 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