Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

Triggers 2 Expand / Collapse
Author
Message
Posted Thursday, April 25, 2013 7:00 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 9:58 AM
Points: 1,325, Visits: 2,285
I was surprised this was your question Hugo. I didn't think it was yours when I saw the Count(*) in the trigger!
Post #1446471
Posted Thursday, April 25, 2013 8:21 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 11:51 AM
Points: 1,423, Visits: 254
Great question, another correction to allow it to work is changing "= 1" to "> 0", obviously without the quotes included.
Thanks,
Lon
Post #1446535
Posted Thursday, April 25, 2013 8:45 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 11, 2014 10:07 AM
Points: 316, Visits: 693
Good question. The code was easier to follow than most lately. Thanks.
Post #1446547
Posted Thursday, April 25, 2013 9:30 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, September 12, 2014 2:10 PM
Points: 2,318, Visits: 1,375
Nice +1.

Not all gray hairs are Dinosaurs!
Post #1446570
Posted Thursday, April 25, 2013 9:49 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:51 PM
Points: 21,733, Visits: 15,424
Thanks Hugo.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1446581
Posted Thursday, April 25, 2013 10:07 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 11:54 AM
Points: 4,427, Visits: 3,423
Very, very nice. Thank you, Hugo!
Post #1446599
Posted Thursday, April 25, 2013 11:23 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, September 12, 2014 11:50 AM
Points: 1,990, Visits: 10,965
Great question, Hugo. Thanks.


Rob Schripsema
Accelitec, Inc
Post #1446646
Posted Thursday, April 25, 2013 12:31 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 8:01 PM
Points: 8,823, Visits: 9,381
Hugo Kornelis (4/25/2013)
L' Eomot Inversé (4/25/2013)
But I have a minor quibble: if this is a business rule, it should be enforced by the schema if possible, not by code; and this is a classic example of a rule that can be enforced by a check constraint.

For a production implementation, I fully agree that a trigger, even a well-coded one, would be a terrible way to implement this rule.
I was pretty sure you would

But for a QotD about triggers, using a CHECK constraint would not have been a very smart choice!

And there's the challenge to ingenuity: devise a rule which can't be implemented as a check constraint (or any other sort of constraint) and therefor has to be implemented as a trigger (because ad hoc updates and inserts and deletes are allowed, so a trigger is the only way you can be sure of executing the code when needed) while at the same time the rule and the trigger are sufficiently non-complex to make a good QotD. I think that might be very difficult, depending on where the commplexity limit is.


Tom
Post #1446669
Posted Thursday, April 25, 2013 7:46 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 11:49 AM
Points: 1,848, Visits: 587
Awesome question..
Thanks..
Post #1446770
Posted Friday, April 26, 2013 3:52 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 5:38 AM
Points: 816, Visits: 154
Nice question Hugo...
Post #1446883
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse