日期:2014-05-17  浏览次数:20577 次

update sql 的难题,请高手支招。
update sql 的难题,请高手支招。

有一个程序,需要用到update 语句来更新字段的值。 要求更新后的值包含本身字段的原值部分。

比如:原有字段值为Fld01="Soft123456" 
想更新为 Fld01="New_Soft123456"

在原值上加上"New_"

sql="Update Tlb01 set Fld01=??????"

cn.Execute sql

请高手帮忙完成sql,谢谢。
update?sql?

------解决方案--------------------
sql="Update Tlb01 set Fld01='New_' + Fld01"

cn.Execute sq
------解决方案--------------------

 Update Tlb01 set Fld01='New_'+Fld01

------解决方案--------------------
update tlb01 set fld01=replace(fld01,'new_'+fld01)
------解决方案--------------------
ACCESS可以这样
update tlb01 set fld01='New_'+mid(fld01,5) where xxxx
sqlserver 的语法反而是 substring(fld01,5,100)
------解决方案--------------------
Update Tlb01 set Fld01='new_'+Fld01 where...

------解决方案--------------------
引用:
Update Tlb01 set Fld01='new_'+Fld01 where...


正解...
------解决方案--------------------
引用:
update tlb01 set fld01=replace(fld01,'new_'+fld01)


这个是正解

------解决方案--------------------
引用:
Quote: 引用:

update tlb01 set fld01=replace(fld01,'new_'+fld01)


这个是正解


正解就给分啊,哈哈