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: 2 days ago @ 9:23 AM
Points: 1,422, Visits: 2,444
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
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 11:51 AM
Points: 1,499, 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: 2 days ago @ 12:13 PM
Points: 321, Visits: 707
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: 2 days ago @ 12:50 PM
Points: 2,500, Visits: 1,586
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: 2 days ago @ 3:20 PM
Points: 18,064, Visits: 16,099
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: Friday, October 24, 2014 12:43 PM
Points: 4,126, Visits: 3,428
Very, very nice. Thank you, Hugo!
Post #1446599
Posted Thursday, April 25, 2013 11:23 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 4, 2014 4:46 PM
Points: 2,018, Visits: 10,973
Great question, Hugo. Thanks.


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


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:21 PM
Points: 7,928, Visits: 9,653
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: 2 days ago @ 11:55 AM
Points: 1,848, Visits: 590
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, November 12, 2014 3:04 AM
Points: 917, Visits: 167
Nice question Hugo...
Post #1446883
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse