Back to Cookbook

Dialect Flip

Translate SQL between any two databases instantly

Paste SQL written for one database and get the equivalent for another. Handles the syntax nightmares — DATEADD vs DATE_ADD, QUALIFY, LIMIT vs TOP, string functions, NULL handling — across Postgres, MySQL, BigQuery, Snowflake, Redshift, SQL Server, and more.

CommunitySubmitted by CommunityWork1 min

PROMPT

Create a skill called "Dialect Flip". I'll paste a SQL query and tell you the source and target databases. Translate the query to the target dialect, handling all syntax differences: date/time functions (DATEADD, DATE_TRUNC, EXTRACT, DATEDIFF), string functions (CONCAT, SUBSTRING, SPLIT), NULL handling (NVL, COALESCE, IFNULL), window functions (QUALIFY, LIMIT vs TOP vs FETCH FIRST), type casting, array/JSON functions, and any other dialect-specific syntax. Add inline comments wherever behavior differs between dialects (e.g., "BigQuery sorts NULLs first by default, Postgres sorts them last"). Warn me about features with no direct equivalent. Support PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake, Redshift, DuckDB, and Oracle.

How It Works

Every database has its own SQL dialect, and the differences are maddening.

Date functions, string functions, window function syntax, NULL handling,

and even basic LIMIT clauses vary across platforms. This skill translates

any SQL query from one dialect to another while preserving the logic.

What You Get

  • Dialect detection from the source SQL
  • Full translation to the target dialect
  • Inline comments where behavior differs (e.g., NULL sorting order)
  • Warnings for features that don't have a direct equivalent
  • Batch translation for migrating entire query repositories

Setup Steps

  1. Ask your Claw to create a "Dialect Flip" skill with the prompt below
  2. Paste your SQL and tell it the target database
  3. Get back the translated query with annotations
  4. For batch work, point it at a directory of .sql files

Tips

  • Most useful during data warehouse migrations (e.g., Redshift → Snowflake)
  • The annotations about behavioral differences are as valuable as the translation itself
  • Test translated queries on a sample before running in production
  • Handles dbt-flavored SQL (Jinja + SQL) by preserving the Jinja blocks
Tags:#sql#migration#databases#productivity