set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[leave] ON [dbo].[attLeaveApplication] AFTER UPDATE AS declare @leaveAppId as numeric declare @leaveId as numeric declare @empid as varchar declare @duration as numeric declare @leavetype as varchar declare @OP as numeric select @leaveAppId=[LeaveAppId],@empid=[EmpID],@duration=[ApprDuration],@leaveId=[LeaveId] from inserted where [ApprFlag]=1 select @leavetype=[LeaveType] from attLeaveTypeMaster where [LeaveId]=@leaveId if @leavetype='CL' Begin select @OP=[CLCL] from attLeaveTransaction where [EmpId]=@empid and DATEPART(Month,[Month])=DATEPART(Month,GetDate()) set @OP = @OP - @duration update attLeaveTransaction set [CLCL]=@OP where [EmpId]=@empid and DATEPART(Month,[Month])=DATEPART(Month,GetDate()) END if @leavetype='PL' Begin select @OP=[PLCL] from attLeaveTransaction where [EmpId]=@empid and DATEPART(Month,[Month])=DATEPART(Month,GetDate()) set @OP = @OP - @duration update attLeaveTransaction set [PLCL]=@OP where [EmpId]=@empid and DATEPART(Month,[Month])=DATEPART(Month,GetDate()) END if @leavetype='SL' Begin select @OP=[SLCL] from attLeaveTransaction where [EmpId]=@empid and DATEPART(Month,[Month])=DATEPART(Month,GetDate()) set @OP = @OP - @duration update attLeaveTransaction set [SLCL]=@OP where [EmpId]=@empid and DATEPART(Month,[Month])=DATEPART(Month,GetDate()) END
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)