REPLACE ( string_replace1 , string_replace2 , string_replace3 )
参数解析:
string_replace1 待搜索的字符串表达式。string_replace1 可以是字符数据或二
进制数据
string_replace2 待查找的字符串表达式。string_replace2 可以是字符数据或二
进制数据。
string_replace3 替换用的字符串表达式。string_replace3 可以是字符数据或二
进制数据。
实例
字符串类型参数:
SELECT REPLACE('abcdefg bcd','bcd','xxx')
结果为:axxxefg xxx
二进制类型参数:
SELECT REPLACE(100111001101,111,000)
SELECT REPLACE(100111001101,111,0)
结果为:100101
结果为:100101
如果参数是支持的字符数据类型之一,并且在string_replace1 中能够找到
string_replace2,那么返回替换后的字符串;反之, 返回 string_replace1;
如果参数是支持的 binary 数据类型之一,则返回二进制数据。
这个函数有一点不足是不支持 text,ntext类型字段的替换