question

habk24 avatar image
habk24 asked

Trigger - to evaluate ANY change to ANY field in the database

I'm looking at creating a trigger to evaluate ANY change in ANY varchar/nvarchar field in the database. If the new value (from the inserted record) contains certain text, it will either do a rollback or send an email to the SQL Administrator. So ... shy of writing individual table triggers (yes, for each of the 100+ tables in my database), is there a database level trigger that can detect that change to a given field? TIA for any thoughts or viable solutions ... Bob
triggertriggers
10 |1200 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
Grant Fritchey avatar image
Grant Fritchey answered
No, there's not a universal INSTEAD OF trigger. If you're looking for something to cover the entire database in this fashion, you'd be better off writing it in the front-end. Otherwise, you'll have to write it for each table. What text or value is going to be universal across the entire database such that you can't let it be written anywhere, ever?
10 |1200 characters needed characters left characters exceeded

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

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.