Sql Server中REPLACE函数的使用
REPLACE
用第三个表达式替换第一个字符串表达式中出现的所有第二个给定字符串表达式。
语法
REPLACE(''string_replace1'',''string_replace2'',''string_replace3'')
参数
''string_replace1''
待搜索的字符串表达式。string_replace1可以是字符数据或二进制数据。
''string_replace2''
待查找的字符串表达式。string_replace2可以是字符数据或二进制数据。
''string_replace3''
替换用的字符串表达式。string_replace3可以是字符数据或二进制数据。
返回类型
如果string_replace(1、2或3)是支持的字符数据类型之一,则返回字符数据。如果string_replace(1、2或3)是支持的binary数据类型之一,则返回二进制数据。
示例
下例用xxx替换abcdefghi中的字符串cde。
SELECTREPLACE(''abcdefghicde'',''cde'',''xxx'')GO
下面是结果集:
------------abxxxfghixxx(1row(s)affected)