它给消息子查询返回了1个以上的值当子查询跟在后面时,这是不允许的

wkyowqbh  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(126)
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)))

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题