The Costs And Benefits Of Triggers

Rob Farley hits on my biggest complaint about triggers:

But the problem isn’t what they do, it’s that you didn’t know it was there. Just like asbestos.

People complain about nested triggers, about triggers that are overly complex, about triggers which do too many things… but stored procedures have all these faults too. It’s just that you knew that the stored procedure was there, and you didn’t know that the trigger was there.

I wish that triggers were more visible inside the tools (Management Studio / Operations Studio / Visual Studio), right alongside stored procedures and procedural functions (those ones that use BEGIN & END and are bad, rather than inline functions). They’re code and should be treated as such.

Hiding triggers under tables makes it easy to forget about them, at least until you get some unexpected results.

Related Posts

T-SQL Tuesday 118 Roundup

Kevin Chant played Santa Claus this month: I hope they had as much fun contributing their posts as I had reading them afterwards. For those who missed the invitation you can read about it here. For some reason I thought it’d be a good idea to do it on my birthday month when I first given […]

Read More

Disabling All Triggers on a Database

Jess Pomfret is on a mission: Sometimes it’s best not to ask why. However, if for some reason you have a number of triggers on tables within a database that you would like to temporarily disable, read on. I came across a situation recently while automating a process to refresh test environments where this exact […]

Read More

Categories

September 2018
MTWTFSS
« Aug Oct »
 12
3456789
10111213141516
17181920212223
24252627282930