Replace a string in a column using oreplace and otranslate functions in Teradata

Sample Table name :Employee

EmployeeId Name Location
123 Keven Newyork
456 david Chicago

OREPLACE Function in Teradata

The OREPLACE function is used to replace the every occurrence of search string in the source_string with the replace_string.

Syntax

SELECT OREPLACE(‘original_string’,’string_to_replace’,’new_string’)

Example

SELECT OREPLACE(Name,’Keven’,’Smith’) as Name from EMPLOYEE;

Name
Smith
david

OTRANSLATE Function in Teradata

The OTRANSLATE function is used to replace the every search characters to the corresponding replace characters in the original string.

Syntax 

SELECT OTRANSLATE(‘original_string’,’search_characters’,’replace_characters’)

Example 

SELECT OTRANSLATE(Name,’di’,’ne’) as Name from employee;

Name
Keven
naven

Recommended Articles