Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

Replace

Example

Substitute occurrences of “i” with “a” in the string.

SELECT Replace(“My name is Willy Wonka”“i”“a”AS ReplaceString;

Definition and Usage

The Replace() function substitutes occurrences of a substring within a string with another substring, optionally limiting the number of replacements.

Syntax

Replace(string1findreplacementstartcountcompare)

Parameter Values

Parameter

Description

string1

Please provide the original string that you would like me to rephrase.

find

Mandatory. The substring to be searched within string1.

replacement

Necessary. The substring to replace find in string1.

start

If not provided, the search in string1 begins at position 1.

count

If not specified, all occurrences of find will be replaced with replacement in string1.

compare

Optional. The type of string comparison:

Possible values:

-1: Use the setting of Option Compare

0: Binary comparison

1: Textual comparison

2: Comparison based on information in your database

Technical Details

Works in:

 From Access 2000