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類型字段的替換