Microsoft KB Archive/79886

= INF: Example of Using Nested Triggers =

Article ID: 79886

Article Last Modified on 2/14/2005

-

APPLIES TO


 * Microsoft SQL Server 6.0 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q79886



SUMMARY
The following script shows the use of nested triggers. The output shows how the inner trigger is completed before the calling trigger is completed.



Script
use pubs go

create table t1(a int) go     create table t2(a int) go     create trigger t1it on t1 for insert as          print 'begin t1it' insert t2 values(1) print 'end  t1it' go

create trigger t2it on t2 for insert as         print 'begin t2it' print 'end  t2it' go

insert t1 values (1) go

Output
begin t1it begin t2it end  t2it end  t1it (1 row affected)

NOTE: If triggers are nested such that a circular link is formed, an error message will be returned indicating that the maximum nesting level has been exceeded.

Keywords: kbinfo kbother KB79886

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.