3 Comments

  1. Anonymous

    Sir, I have a doubt if i create after insert trigger on same table will the trigger never stop or what will happen.

    Reply

  2. Hello friend I did not get your question. But I am assuming that your question is that, If you create a trigger on “EMP” table and in the trigger body, you have written insert query for same table. Answer for this question is that, trigger will be called one time and insert the row into the table. it will not go in recursion mode.(If recursion mode is disabled)this is default setting in SQL 2008 that recursion is disabled. but if you enable the recursion feature trigger will throw an error message after getting in loop. SQL only support 32 level recursion.

    you can enable or disable recursion feature using below script.

    ALTER DATABASE your-database-name
    SET RECURSIVE_TRIGGERS OFF

    ALTER DATABASE your-database-name
    SET RECURSIVE_TRIGGERS ON

    Please let me know, if you have further queries.

    Reply
  3. Anonymous

    Thankx Sir. Your assumption is correct and gr8.
    This means recursive trigger will insert 32 rows if recursive triggers setting is on.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>