本帖最后由 llcaesar163 于 2011-11-01 10:48:09 编辑

解决方案 »

  1.   

    case when Score+10000>=15000 then 15000 else score+10000 end as score
      

  2.   

    update [Money]
    set Score=Score+10000
    where Score<15000這樣?
      

  3.   

    update tb set score = (case when score <= 5000 then score + 10000 else 15000 end) 
      

  4.   

    use Tempdb
    go
    --> --> 
     
    if not object_id(N'Tempdb..#Money') is null
    drop table #Money
    Go
    Create table #Money([id] int,[Score] int)
    Insert #Money
    select 1,1000 union all
    select 2,4000 union all
    select 3,5000 union all
    select 4,2000 union all
    select 5,6000 union all
    select 7,1000
    GoUPDATE  #Money set Score=Score+10000 WHERE [Score]<15000
    while @@ROWCOUNT>0
    UPDATE  #Money set Score=Score+10000 WHERE [Score]<15000
    GO
    SELECT * FROM #Money/*id Score
    1 21000
    2 24000
    3 15000
    4 22000
    5 16000
    7 21000
    */
      

  5.   

    還是這樣use Tempdb
    go
    --> --> 
     
    if not object_id(N'Tempdb..#Money') is null
    drop table #Money
    Go
    Create table #Money([id] int,[Score] int)
    Insert #Money
    select 1,1000 union all
    select 2,4000 union all
    select 3,5000 union all
    select 4,2000 union all
    select 5,6000 union all
    select 7,1000
    GoUPDATE  #Money set Score=CASE WHEN Score+10000>=15000 THEN 15000 ELSE Score+10000 end WHERE [Score]<15000SELECT * FROM #Money/*
    id Score
    1 11000
    2 14000
    3 15000
    4 12000
    5 15000
    7 11000*/