Lalitha
Lalitha

Reputation: 69

SQL Server trigger latency?

I have created a trigger for a table in SQL Server 2008

CREATE TRIGGER trigger_mytable
ON dbo.mytable

FOR INSERT, DELETE, UPDATE

AS 

EXTERNAL NAME mycode.[trig.mytable].myfn

The code for mytable.myfn is in C#. It opens a connection to the database and queries the inserted or deleted table based on the event to get the trigger data. Can it be possible that an entry is inserted and immediately deleted (in like a fraction of a second or say ms) from the table and the trigger function is never called? In short can there be a latency or absence of trigger? My understanding is that triggers use interrupt sort of mechanism rather than polling. I am very new to SQL Server and triggers.

Upvotes: 0

Views: 333

Answers (1)

gbn
gbn

Reputation: 432401

No: there is no latency or lag

The trigger is part of the INSERT and DELETE statement.
When the trigger completes, then SQL Server reports the INSERT or DELETE as complete

Note: you'd typically keep triggers short and concise and not use external code or calls

Upvotes: 2

Related Questions