Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Triggers and stored procedures - life cycle and multiple instances

$
0
0

I'm working on a project developed by someone else (who is no longer available), and I have some questions about how the current design operates.

SQL Server 2008 R2, in case that's relevant.

There's a table trigger that is fired whenever one of three fields (A, B, C) is updated. In the trigger code, field D in the table is set to '?' for every record appearing in the Inserted table. Then, a stored procedure is called and that's the end of the trigger code.

First question: If the trigger fires because field A is updated on a record, at what point does the trigger become eligible to fire again? Immediately? Or after the first instance of the trigger code has finished executing? If the latter, when is the trigger code considered to have finished? After the stored procedure is called, or after the stored procedure has completed executing?

In the stored procedure, all records with field D = '?' are cycled through (using a Select Top 1 query that repeats until there are no more) and, after some various logic steps field D is updated to a non-? value. When there are no more rows with field D = '?' then the stored procedure exits.

Second question: Once the stored procedure has begun running, when is it eligible to run again? Immediately? Or after the first instance has finished executing?


Viewing all articles
Browse latest Browse all 23857

Trending Articles