ALTER TRIGGER [dbo].[AfterDELETETrigger]
ON [dbo].[TBLEmployeesBranches]
FOR DELETE
AS
DECLARE @Employee_Name nvarchar(75),
@Region_Name nvarchar(75),
@MainBranch nvarchar(75),
@Branch_Name nvarchar(75),
@UserName nvarchar(75),
@EmployeeID int,
@AddedByUser int
SET @Employee_Name = (SELECT Employee_Name
FROM deleted
INNER JOIN TBEmployees ON deleted.EmployeeID = TBEmployees.Employee_ID)
SET @Region_Name = (SELECT Region_Name
FROM deleted
INNER JOIN TBRegions ON deleted.RegionID = TBRegions.Region_ID)
set @MainBranch=(select MainBranch from deleted inner join TBLMainBranch on deleted.MainBranchID=TBLMainBranch.MainBranchID)
set @Branch_Name=(select Branch_Name from deleted inner join TBBranches on deleted.BranchID=TBBranches.Branch_ID)
set @AddedByUser=(select AddedByUser from deleted)
insert into TBLAudit (ReservationNumber,AuditName)
Values
(@EmployeeID,'Delete Branch From Employee Name '+ cast(@Employee_Name as nvarchar(25))+' Region name ' + cast(@Region_Name as nvarchar (30))+
'Main Branch '+ cast(@MainBranch as nvarchar(50))+'Branch Name '+cast(@Branch_Name as nvarchar(75))+' Added By User Name '+CAST(@UserName as nvarchar(150))
+' Added By '+cast(@Employee_Name as nvarchar (30))+ +' Delete At : ' +CAST(getdate() as nvarchar(50)))
暂无答案!
目前还没有任何答案,快来回答吧!