sql server中replace()函数用法解析

来源:互联网 发布:leetcode python 编辑:程序博客网 时间:2024/05/22 10:36

知识点一: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。

知识点三:replace()的返回值

如果参数是支持的字符数据类型之一,并且在string_replace1 中能够找到 string_replace2,那么返回替换后的字符串;反之, 返回 string_replace1;如果参数是支持的 binary 数据类型之一,则返回二进制数据。

知识点四:实例

1,字符串类型参数:

SELECT REPLACE('abcdefg bcd','bcd','xxx')

结果为:axxxefg xxx

2,二进制类型参数:

SELECT REPLACE(100111001101,111,000)

结果为:1000001101

本文参考了:http://www.cnblogs.com/remember-forget/p/5993526.html

0 0
原创粉丝点击