日期:2014-05-18  浏览次数:20606 次

為什麽批量更新以後,觸發器只影響了一條數據?
ALTER   TRIGGER   [dbo].[reqLocalCadreUpdate]   ON     [dbo].[reqLocalCadre]   AFTER   UPDATE
AS  
BEGIN
Declare   @RequireID                         bigint,
@RequireCode                     varchar(50),
@BUCode                               varchar(50),
@DeptID                               varchar(50),
@PositionSerialCode       varchar(20),
@PostCode                           varchar(20),
@GradeCodeMin                   varchar(20),
@GradeCodeMax                   varchar(20),
@RequireNumber                 int,
@IsInProject bit,
@ApproveCompleteTime datetime,

@RequireID_old                         bigint,
@RequireCode_old                     varchar(50),
@BUCode_old                               varchar(50),
@DeptID_old                               varchar(50),
@PositionSerialCode_old       varchar(20),
@PostCode_old                           varchar(20),
@GradeCodeMin_old                   varchar(20),
@GradeCodeMax_old                   varchar(20),
@RequireNumber_old                 int,
@IsInProject_old bit,
@ApproveCompleteTime_old datetime

select   @RequireID=RequireID,@RequireCode=RequireCode,@BUCode=BUCode,@DeptID=DeptID,@PositionSerialCode=PositionSerialCode,@PostCode=PostCode,@GradeCodeMin=GradeCodeMin,@GradeCodeMax=GradeCodeMax,@RequireNumber=RequireNumber,   @IsInProject=IsInProject,   @ApproveCompleteTime=ApproveCompleteTime   from   inserted
select   @RequireID_old=RequireID,@RequireCode_old=RequireCode,@BUCode_old=BUCode,@DeptID_old=DeptID,@PositionSerialCode_old=PositionSerialCode,@PostCode_old=PostCode,@GradeCodeMin_old=GradeCodeMin,@GradeCodeMax_old=GradeCodeMax,@RequireNumber_old=RequireNumber,   @IsInProject_old=IsInProject,   @ApproveCompleteTime_old=ApproveCompleteTime   from   deleted

--RequireCode
if   @RequireCode!=@RequireCode_old
begin
select   @RequireCode=RequireCode   from   inserted
update   schRecruitPlan   set   RequireCode=@RequireCode   where   RequireID=@RequireID   and   HasDeleted=0
update   pubJobAnnounce   set   RequireCode=@RequireCode   where   RequireID=@RequireID
print   'RequireCode   updated! '
end

--BUCode
if   @BUCode!=@BUCode_old
begin
select   @BUCode=BUCode   from   inserted
update   schRecruitPlan   set   BUCode=@BUCode   where   RequireID=@RequireI