question

sqlnewb avatar image
sqlnewb asked

Triggers to perform an audit

I am trying to write a set of querires that sends alerts based on certain criteria. What is the best way to go about this? Should I create a trigger? For example Select * from tableA where colA > colB
sql-server-2008t-sqltrigger
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
A trigger (or at least a DML one) is designed to fire on data manipulation events, i.e. UPDATE, INSERT DELETE. If you can capture the data condition at the point of entry, then triggers may be a way of doing this. If not then you are probably best having a scheduled task that runs frequently and fires some action/alert depending on the condition defined.
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·
Depending on the quantity of data, and the indexing, and the threshold time between data breaching condition and alert being generated, the scheduled task could be a bit of a performance nightmare. Just saying.
1 Like 1 ·
Kev Riley avatar image Kev Riley ♦♦ commented ·
Oh yes I would agree, but it just seemed from the phrasing of the OP that he wants to do this after-the-event, and the only way I can think of determining if the condition exists, is to ask the question, psuedo-constantly. I don't like it any more than you do!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.