Convert PostgreSQL to SQL Server

A free online converter that translates PostgreSQL queries into SQL Server. Paste your SQL, press Translate, and Query Studio rewrites the syntax that differs between the two databases — instantly, with no login and nothing stored.

Open in the editor →All Query Studio tools

PostgreSQLSQL Server example

Here is a real PostgreSQL query and the SQL Server output Query Studio produces:

PostgreSQL input
SELECT u.id, u.name, COUNT(o.id) AS orders
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.created_at > '2024-01-01' AND u.active = TRUE
GROUP BY u.id, u.name
HAVING COUNT(o.id) > 3
ORDER BY orders DESC
LIMIT 10;
SQL Server output
SELECT
  TOP 10 u.id,
  u.name,
  COUNT(o.id) AS orders
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.created_at > '2024-01-01'
  AND u.active = TRUE
GROUP BY
  u.id,
  u.name
HAVING
  COUNT(o.id) > 3
ORDER BY
  orders DESC;

What changes from PostgreSQL to SQL Server

  • Identifier quoting is rewritten from double-quoted "identifiers" to bracketed [identifiers].
  • Row limiting is converted from PostgreSQL's LIMIT n to SQL Server's TOP n, including any OFFSET for pagination.
  • Null-handling functions such as COALESCE() are mapped to ISNULL().
  • Current-timestamp functions like NOW() / CURRENT_TIMESTAMP become GETDATE().
  • The result is re-indented and keyword-cased in SQL Server style so it's ready to paste and run.

How to convert PostgreSQL to SQL Server

  1. Open the Query Studio editor and choose PostgreSQL as the “From” dialect.
  2. Choose SQL Server as the “To” dialect.
  3. Paste your PostgreSQL query and press Translate — copy the SQL Server result.

Try it with your own query

The editor is preloaded with PostgreSQLSQL Server. You can also explain, format, validate and analyze the result.

Convert PostgreSQL to SQL Server now →

PostgreSQL to SQL Server FAQ

Is this PostgreSQL to SQL Server converter free?

Yes — it's completely free with no account, no sign-up and no usage limits. Your query is processed to return the result and never stored.

Is the PostgreSQL to SQL Server conversion accurate?

Query Studio rewrites syntax deterministically using real SQL parsers, so it gives the same result every time. It handles the common differences automatically; always review complex, vendor-specific queries before running them in production.

Can I convert SQL Server back to PostgreSQL?

Yes. Use the SQL Server to PostgreSQL converter, or press the Swap (⇄) button inside the editor to flip the direction instantly.

Other conversions

SQL Server to PostgreSQLMySQL to PostgreSQLPostgreSQL to MySQLMySQL to SQL ServerSQL Server to MySQLMySQL to Google BigQueryPostgreSQL to Snowflake