Monday, September 22, 2008

Replace the Value of the field in a particular position in SQL:

A particular position or a particular value in a string can be replaced with a new value in SQL. REPLACE function does the job.
Syntax:

REPLACE (string_expression1, string_expression2, string_expression3)
string_expression1
Is the string expression to be searched. string_expression1 can be of a character or binary data type.
string_expression2
Is the substring to be found. string_expression2 can be of a character or binary data type.
string_expression3
Is the replacement string. string_expression3 can be of a character or binary data type.
Example:
UPDATE kgipkemp set kmfld1 = REPLACE(kmfld1,substr(kmfld1,21,6), '080901' )

No comments: