Good morning everybody.
I made a sp that works perfectly, but when I create the trigger to execute it it gives error.
I tried to create a trigger with the same sql query but it also doesn't work help me please
[edit]
The SP makes an update on the EmpAttendance table column SubDiario when the change in the table EmpSalary column SubDiario
and it works, but when I try to trigger the sp "EXEC [dbo]. [sp_SubMensal_update] gives an error" Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32). "
[/edit]
What I have tried:
ALTER PROCEDURE [dbo].[sp_SubMensal_update]
AS
BEGIN
update a set
a.SubDiario=s.SubDiario
from EmpAttendance a
join EmpSalary s on s.EmpId=a.EmpId
where a.time_registered > getdate() -1
END
create TRIGGER [dbo].[spSubMensal_update]
ON [dbo].[EmpAttendance]
AFTER INSERT,UPDATE,DELETE AS BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
update a set
a.SubDiario=s.SubDiario
from EmpAttendance a
join EmpSalary s on s.EmpId=a.EmpId -
where a.time_registered > getdate() -1
END