USE [PMS]
GO
/****** Object: Trigger [dbo].[tr_TaskInfo_Update] Script Date: 06/08/2013 20:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tr_TaskInfo_Update]
ON [dbo].[TaskInfo]
AFTER UPDATE
AS
BEGIN TRANSACTION
DECLARE @OldIsFinish BIT
DECLARE @NewIsFinish BIT
DECLARE @PlanId INT
DECLARE @Count INT
SELECT @NewIsFinish=IsFinish,@PlanId=PlanId FROM INSERTED
SELECT @OldIsFinish =IsFinish FROM DELETED
IF(@PlanId<>0 AND @NewIsFinish<>@OldIsFinish)
BEGIN
IF(@OldIsFinish=1)
BEGIN
UPDATE dbo.PlanDetailInfo SET IsFinish='0' WHERE PlanDetailId=@PlanId
END
ELSE
BEGIN
SELECT @Count=COUNT(*) FROM dbo.TaskInfo WHERE IsFinish='0' AND PlanId = @PlanId AND IsView='1'
IF(@Count=0)
BEGIN
UPDATE dbo.PlanDetailInfo SET IsFinish='1' WHERE PlanDetailId=@PlanId
END
END
END
IF(@@ERROR<>0)
ROLLBACK TRAN
ELSE
COMMIT TRAN
SELECT @Count=COUNT(*) FROM dbo.TaskInfo WHERE IsFinish='0' AND PlanId = @PlanId AND IsView='1'
把这个select语句中的条件去掉两个就能运行,不去掉就运行不了
去掉和不去掉 都可以编译通过啊 不知道你说的什么问题