---
schema_version: "1"
id: f6a418fbb1b614656703477152c673fa1d8643f981ea5cc80f275a49149fadae
title: replace({str}, {old_str}, {new_str})
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_sql/guides/bi-sql-string-replace.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-sql/guide/bi-sql-string-replace.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 9823998af37792ab2287239413e62ab59b092a405dac89860739d733887da4f7
products:
  - SQL for Analytics Developer Guide
  - analytics
---

# replace({str}, {old_str}, {new_str})

Replaces all occurrences in string _str_ of a substring _old_str_ with a new substring _new_str_. Returns a new string.

## Example

This example replaces instances of 'Al' with 'AL' in the City column. The query returns the first five entries.

```nolang
SELECT replace(City, 'Al', 'AL') as "City"
From "Superstore"
GROUP BY City
LIMIT 5;
```

| City        |
| ----------- |
| Aberdeen    |
| Abilene     |
| Akron       |
| ALbuquerque |
| ALexandria  |
