FroshKiller All American 51913 Posts user info edit post |
Everyone hates triggers. I know that. I want you to give me good use cases where a trigger was the right choice. Tell me what you considered and tried before settling on the trigger, and tell me what you did to document and support the trigger going forward. 7/26/2010 3:10:05 PM |
Shaggy All American 17820 Posts user info edit post |
i love triggers and hate documentation 7/26/2010 3:13:04 PM |
DeltaBeta All American 9417 Posts user info edit post |
7/26/2010 3:14:43 PM |
FroshKiller All American 51913 Posts user info edit post |
yeah i know that but at least i'm talking about a microsoft product this time ok 7/26/2010 3:14:54 PM |
qntmfred retired 40816 Posts user info edit post |
Quote : | "Everyone hates triggers" |
7/26/2010 3:16:04 PM |
Shaggy All American 17820 Posts user info edit post |
triggers are for hacks. ex: 3rd party app puts updates and inserts into a table. Changing the table structure breaks the app. i want to record what hostname did the insert/update. I create a trigger that does an insert of the hostname + key into another table. 7/26/2010 3:18:16 PM |
Shaggy All American 17820 Posts user info edit post |
sometimes i like to say im gonna do something with a trigger just to make the dba squirm
[Edited on July 26, 2010 at 3:20 PM. Reason : i] 7/26/2010 3:19:30 PM |
FroshKiller All American 51913 Posts user info edit post |
Every tool has a use! 7/26/2010 3:21:34 PM |
Wolfmarsh What? 5975 Posts user info edit post |
I use triggers a lot in one of our internal project databases. They do have thier place.
I can't give you a ton of information on why I chose this route, but suffice it to say that indexes and constraints didnt give us the functionality we needed in order to have the rows react to specific scenarios.
I would say the use of triggers in this particular database allows an analyst to spend approximately 10-20% less hours on each client project than if the triggers didnt exist. 7/26/2010 7:14:27 PM |
1985 All American 2175 Posts user info edit post |
I'm pretty green at SQL stuff, so I don't know if this is the proper usage (please tell me if I could have done it better?), but I've got triggers on the table that holds product prices, so when software updates our DB prices, triggers fire to send price modifies to our affiliate websites.
(because quite a few things have the capability to change prices)
[Edited on July 26, 2010 at 7:51 PM. Reason : .] 7/26/2010 7:48:49 PM |
Wolfmarsh What? 5975 Posts user info edit post |
For me, I would think the usage there really depends on the way you are pushing the prices to the affiliate sites.
For example, I normally avoid creating triggers that have dependencies on external objects, i.e. things that you have no control over. 7/26/2010 8:28:28 PM |
OmarBadu zidik 25073 Posts user info edit post |
triggers are extremely useful when a solution can't be rebuilt but a trigger can be added on the fly 7/26/2010 9:11:42 PM |
AntecK7 All American 7755 Posts user info edit post |
I used them for keeping a history of database records..
But then im running vbscript code
Shrug. 7/27/2010 9:37:19 PM |