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


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 11:42 AM
Points: 1,517, Visits: 2,571
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
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, February 19, 2015 10:04 AM
Points: 1,587, Visits: 255
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: Friday, January 9, 2015 10:45 AM
Points: 329, Visits: 717
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: Yesterday @ 10:57 AM
Points: 2,584, Visits: 1,675
Nice +1.

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


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:41 PM
Points: 18,416, Visits: 16,584
Thanks Hugo.



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
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 @ 9:08 AM
Points: 4,322, Visits: 3,508
Very, very nice. Thank you, Hugo!
Post #1446599
Posted Thursday, April 25, 2013 11:23 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, March 24, 2015 5:24 PM
Points: 2,090, Visits: 10,985
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 @ 4:12 AM
Points: 8,238, Visits: 9,944
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


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, March 13, 2015 12:40 PM
Points: 2,070, Visits: 595
Awesome question..
Thanks..
Post #1446770
Posted Friday, April 26, 2013 3:52 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, March 18, 2015 4:24 AM
Points: 1,030, Visits: 168
Nice question Hugo...
Post #1446883
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse