如何更新一个表的列值比较其他表条件

如何更新一个表的列值比较其他表条件

本文介绍了如何更新一个表的列值比较其他表条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

update Attendence set Att_UpdateBit='0'
where fk_Att_EmpCode   In (select pk_Emp_Code
                           from EmployeeMaster
                           where ((@ATReprs_Location='All') or (fk_Emp_LocCode=@ATReprs_Location)) and
                             ((@ATReprs_Catagory='All')or (fk_Emp_CatCode=@ATReprs_Catagory)) and
                             ((@ATReprs_Department='All') or (fk_Emp_DepCode=@ATReprs_Department)))and
                                Att_Date>=@ATreprs_Fromdate and Att_Date<=@ATreprs_Todate

    



 here i am using store procedure and i am paasing parameter  and i am updating one table column from comparing other table condition with condition .Its Working  fast only 50 employe ,,but if i update using "excel upload It will tak eso much time after it show "sql query time out " please can any one help me

推荐答案

update atten set atten.Att_UpdateBit='0' from Attendence atten
 join EmployeeMaster Emp on (Emp.@ATReprs_Location=atten.fk_Emp_LocCode or Emp.@ATReprs_Location='All')  and
 (atten.fk_Emp_CatCode=Emp.@ATReprs_Catagory  or Emp.@ATReprs_Catagory='All')
 and(atten.fk_Emp_DepCode=Emp.@ATReprs_Department or  Emp.@ATReprs_Department='All')
 where  Att_Date>'some date'


这篇关于如何更新一个表的列值比较其他表条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:57