简体   繁体   中英

Maximum Nesting of levels in SQL Server after trigger

I created a new trigger that would let me create a log after updating, however even though i think it should work i get the following error:

The maximum nesting level of views, stored procedures, functions or triggers was exceeded (limit: 32).

Is it possible that it has something to do with how the trigger is written?

ALTER TRIGGER [TR_Log_Notes]
ON ALUMNS
AFTER UPDATE
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @Note_Text VARCHAR (30)
    SET @Note_Text = 'Fields were updated'

    INSERT INTO Log_Notes(Alumn_ID, Note_Text)
        SELECT i.Alumn_ID, @NoteText 
        FROM INSERTED i
END

You are inserting into log_notes after updating a row in the same table. Is that really what you intend?

If you do intend the same table, then you should use a for trigger, and update each row before it goes into the table. However, I suspect that you want to create the trigger on a different table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM