B_Process 表
id,ShipID, Ca
 1  H1001  33
 2  H1002  44
 如果 ca 字段 不包括a 就更新 变成33a,a是我程序过去的变量。
 用SQL 实现,包有a就还是 本身字段还是33(ID 1为例)
 update B_Process set Ca+'a'  where ???  能用 SQL ’用条件' 实现 就是那个a 在里面 就拼接字符, 33a    下次再传变量 b 就是 33ab  再下次 又a  就是 33ab...

解决方案 »

  1.   

    update B_Process set Ca+@str where charindex(@str,ca)=0 
      

  2.   


    update tb
    set ca = ca + (case when charindex('a',ca) > 0 then '' else 'a' end)
      

  3.   


    -- 'a' 可以换为变量。update tb
    set ca = ca + 'a'
    where charindex('a',ca) > 0
      

  4.   


    写错。
    -- 'a' 可以换为变量。update tb
    set ca = ca + 'a'
    where charindex('a',ca) = 0
      

  5.   


    update B_Process set Cat=Cat+'a' where charindex('a',Cat)=0
      

  6.   

    declare @char varchar(1)
    set @char='a'
    update B_Process set Ca=Ca+@char where charindex(@char,Ca)=0
      

  7.   


    update B_Process set Cat=substring(Cat,charindex('a',Cat),len('a')) where charindex('a',Cat)=0
      

  8.   

    要是变成空的话 就update B_Process set Cat=replace(Cat,'a','') where charindex('a',Cat)=0