Recursive behavior of triggers in SQL Server 6.5 is incorrect (304364)
The information in this article applies to:
This article was previously published under Q304364 SYMPTOMS
With SQL Server 6.5, a trigger cannot recursively call itself. A trigger does not call itself in response to a second update to the same table within the trigger. For example, if an UPDATE trigger on one column of a table results in an update to another column, the UPDATE trigger activates only once rather than repeatedly.
However, in SQL Server 6.5, you can circuitously implement a recursive trigger if the trigger executes a stored procedure that updates the same table. The implementation causes the trigger to fire repeatedly if "nested triggers" is enabled.
The circuitous implementation of a recursive trigger with a stored procedure is not supported in SQL Server 6.5 and should not be used.
In SQL Server 7.0 or later, you can use recursive triggers if the database option RECURSIVE TRIGGER is set to ON. When the RECURSIVE TRIGGER option is set ON, updates that use either Data Manipulation Language (DML) statements (UPDATE, DELETE, INSERT) or stored procedures within the trigger against the same table fire the trigger again. Setting the RECURSIVE TRIGGER option to OFF disables all recursion, including any that is initiated by the trigger stored procedure.
WORKAROUND
To work around the problem:
- If you are migrating from SQL Server 6.5, the application may be able to use true indirect trigger recursion in SQL Server 7.0 or later.
- You may be able to use an INSTEAD OF trigger for SQL Server 2000 or later.
Modification Type: | Major | Last Reviewed: | 12/27/2004 |
---|
Keywords: | kbprb KB304364 |
---|
|