REPLACE
用第三個(gè)表達(dá)式替換第一個(gè)字符串表達(dá)式中出現(xiàn)的所有第二個(gè)給定字符串表達(dá)式。
語(yǔ)法
REPLACE ( ''string_replace1'' , ''string_replace2'' , ''string_replace3'' )
參數(shù)
''string_replace1''
待搜索的字符串表達(dá)式。string_replace1 可以是字符數(shù)據(jù)或二進(jìn)制數(shù)據(jù)。
''string_replace2''
待查找的字符串表達(dá)式。string_replace2 可以是字符數(shù)據(jù)或二進(jìn)制數(shù)據(jù)。
''string_replace3''
替換用的字符串表達(dá)式。string_replace3 可以是字符數(shù)據(jù)或二進(jìn)制數(shù)據(jù)。
返回類型
如果 string_replace(1、2 或 3)是支持的字符數(shù)據(jù)類型之一,則返回字符數(shù)據(jù)。如果 string_replace(1、2 或 3)是支持的 binary 數(shù)據(jù)類型之一,則返回二進(jìn)制數(shù)據(jù)。
示例
下例用 xxx 替換 abcdefghi 中的字符串 cde。
SELECT REPLACE(''abcdefghicde'',''cde'',''xxx'')GO
下面是結(jié)果集:
------------abxxxfghixxx(1 row(s) affected)
您可能感興趣的文章:- SQL server中字符串逗號(hào)分隔函數(shù)分享
- Sqlserver 自定義函數(shù) Function使用介紹
- SQL Server實(shí)現(xiàn)split函數(shù)分割字符串功能及用法示例
- sql server如何利用開(kāi)窗函數(shù)over()進(jìn)行分組統(tǒng)計(jì)
- SQL Server 常用函數(shù)使用方法小結(jié)