Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6744889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:08:16+00:00 2026-05-26T12:08:16+00:00

When recursions on triggers is enabled in SQL Server and I update the same

  • 0

When recursions on triggers is enabled in SQL Server and I update the same table within an after trigger, when is the nested (recursive) trigger executed:

  • Within execution of the source trigger?
  • When the original trigger has finished it’s work?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:08:17+00:00Added an answer on May 26, 2026 at 12:08 pm
    CREATE TABLE T ( C INT  )
    
    GO
    
    CREATE TRIGGER TR_T
    ON T 
    AFTER UPDATE
    AS
    BEGIN
    RAISERROR('TR - Entered @@NESTLEVEL=%d',0,1,@@NESTLEVEL)
    IF @@NESTLEVEL < 5
         UPDATE T SET C=@@NESTLEVEL
    RAISERROR('TR - Exited @@NESTLEVEL=%d',0,1,@@NESTLEVEL)
    END
    
    
    GO
    SET NOCOUNT ON
    UPDATE T SET C=12
    

    Output

    TR - Entered @@NESTLEVEL=1
    TR - Entered @@NESTLEVEL=2
    TR - Entered @@NESTLEVEL=3
    TR - Entered @@NESTLEVEL=4
    TR - Entered @@NESTLEVEL=5
    TR - Exited @@NESTLEVEL=5
    TR - Exited @@NESTLEVEL=4
    TR - Exited @@NESTLEVEL=3
    TR - Exited @@NESTLEVEL=2
    TR - Exited @@NESTLEVEL=1
    

    Conclusion: The child trigger fires when the DML statement in the parent trigger is executed then control is returned back to the parent trigger which can potentially execute additional code after the DML statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a general AFTER UPDATE trigger for my users table to check if
How many maximum recursion level possible for CTE in SQL server? If maximum recursion
I have written an update trigger, that does an update that could potentially call
I have a problem with a recursive SQL function. The original problem is that
I never use the comma operator. But sometimes, when I write some recursions, I
Let's say you have a table for branches in your organization. Some of them
My program requires multiple random recursions, and I have to manually let the script
I have a strongly recursive function, that creates a (very small) std::multimap locally for
Possible Duplicate: Split string in SQL I have seen a couple of questions related
What is the cleanest way to pass the result of this recursive function back

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.