How to Use REPLACE in BigQuery
Last updated August 23, 2026 · By the SaturnSQL team
REPLACE(value, from, to) swaps every literal occurrence, with no regex involved. Use REGEXP_REPLACE when what you are matching is a pattern.
All three arguments are plain strings, so metacharacters have no special meaning and nothing needs escaping. Passing an empty string as the third argument deletes the matched text.
SELECT REPLACE(url, 'http://', 'https://') AS secure_url,
REPLACE(sku, '-', '') AS sku_digits
FROM pages, products;Replacing several things at once
REPLACE handles one pair per call, so multiple substitutions mean nesting it. Past two or three, a single REGEXP_REPLACE with an alternation is easier to read and cheaper than the nest.
SELECT REGEXP_REPLACE(raw, r'(\r\n|\r|\n)', ' ') AS one_line
FROM imports;Not the same as the REPLACE keyword
SQL also uses the word in CREATE OR REPLACE TABLE and in SELECT * REPLACE (expr AS col), which substitutes one column's value in a star expansion. Those are statement syntax, unrelated to the string function.
SELECT * REPLACE (UPPER(country) AS country)
FROM users;Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free