各位朋友,
如何使用replace...with...for...语句,替换字符串的前两位?
情况如下:
域hist_refno值'KW'开头的字符串替换成'ZZ'开头。
运行:replace left(hist_refno, 2) with 'ZZ' for left(hist_refno, 2)='KW',提示说不可认知。
请问该如何做?
紧急!
谢谢!!
------解决方案--------------------------------------------------------
replace hist_refno with 'ZZ'+subs(hist_refno,3) for left(hist_refno, 2)='KW'
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
这样速度快:
REPLACE hist_refno WITH STUFF(hist_refno, 1, 2, 'ZZ') FOR LIKE('KW*',hist_refno)
------解决方案--------------------------------------------------------
STUFF() 函数更有效一些。
------解决方案--------------------------------------------------------
不错,收了
------解决方案--------------------------------------------------------
Use 表名
Replace All hist_refno With "ZZ"+Substr(Alltrim(hist_refno),3) For Upper(Left(Alltrim(hist_refno),2))="KW"
或
Update 表名 hist_refno="ZZ"+Substr(Alltrim(hist_refno),3) Where Upper(Left(Alltrim(hist_refno),2))="KW"
------解决方案--------------------------------------------------------
replace hist_refno with 'ZZ'+subs(hist_refno,3) for left(hist_refno, 2)='KW'
or
REPLACE hist_refno WITH STUFF(hist_refno, 1, 2, 'ZZ') FOR LIKE('KW*',hist_refno)