更新字段

update  table set table.field=

(

  case when 条件

  then 值1

  else 值2 end  

)

where 条件

如:update BM_TrainingPeriod set IsValid=(
                         case when exists(select 1 From BM_TrainingGroup y where BM_TrainingPeriod.id=y.TrainingPeriodid and IsValid=1)
                            then 1
                            else 0
                            end
                        )
                        where id=@TrainingPeriodID

posted on 2013-10-09 09:45  dengjd  阅读(143)  评论(0编辑  收藏  举报

导航