SQL SERVER replace()函数说明

一. replace()的语法

REPLACE ( string_replace1 , string_replace2 , string_replace3 )

参数解析:
string_replace1 待搜索的字符串表达式。string_replace1 可以是字符数据或二
进制数据
string_replace2 待查找的字符串表达式。string_replace2 可以是字符数据或二
进制数据。
string_replace3 替换用的字符串表达式。string_replace3 可以是字符数据或二
进制数据。

二. replace()的作用

用string_replace3替换string_replace1中出现的所有string_replace2。

三. 实例

1,字符串类型参数:

SELECT REPLACE(‘abcdefg bcd’,‘bcd’,‘xxx’)
结果:
axxxefg xxx

2,二进制类型参数:

SELECT REPLACE(100111001101,111,000)
结果:
1000001101

猜你喜欢

转载自blog.csdn.net/Dreamy_zsy/article/details/107788751