Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Career
»
Presentations and Speaking
»
Critique - Common SQL Server Mistakes
40 posts, Page 2 of 4
««
1
2
3
4
»
»»
Critique - Common SQL Server Mistakes
Rate Topic
Display Mode
Topic Options
Author
Message
L' Eomot Inversé
L' Eomot Inversé
Posted Thursday, January 20, 2011 6:58 PM
SSCertifiable
Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 7,110,
Visits: 7,184
Question: why do you think multi-row triggers are a mistake? My view is that if you need triggers then single row triggers are usually a mistake, but multi-row triggers are fine.
Tom
Is minic a gheibheann béal oscailte dorn dúnta.
Is minig a cheapas beul fosgailte dòrn dùinte.
Post #1051273
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Thursday, January 20, 2011 9:25 PM
SSC-Dedicated
Group: Administrators
Last Login: Yesterday @ 3:30 PM
Points: 31,436,
Visits: 13,751
The NULL mistake is that people often write
where a.col = null
instead of
where a.col is null
The multi-row trigger is the same. Developers assume triggers fire once per row, instead of once per transaction. I have examples of why this is an issue.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #1051308
Koen Verbeeck
Koen Verbeeck
Posted Friday, January 21, 2011 12:26 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 2:11 AM
Points: 9,378,
Visits: 6,473
Steve Jones - SSC Editor (1/20/2011)
The NULL mistake is that people often write
where a.col = null
instead of
where a.col is null
Oh allright. Pfieuw, I was afraid I had to rewrite all my code
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1051361
GSquared
GSquared
Posted Friday, January 21, 2011 7:35 AM
SSCoach
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 1:55 PM
Points: 15,442,
Visits: 9,571
Koen (da-zero) (1/20/2011)
I would go to a session like this one.
I'm always eager to learn from more experienced people who have already learned from mistakes, so that I can avoid them
One question: what is wrong with IS NULL?
Joe Celko personally dislikes it. I think it said something mean about his shoes one day.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1051528
ALZDBA
ALZDBA
Posted Friday, January 21, 2011 9:03 AM
SSCertifiable
Group: General Forum Members
Last Login: Wednesday, May 22, 2013 2:17 AM
Points: 6,862,
Visits: 8,049
- why all your columns by default should be NOT NULL ! unless you really really really need to know no value has been provided (and the datatype default doesn't suit your datamodel.)
Johan
Jul 13
Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere
-
How to post Performance Problems
-
How to post data/code to get the best help
-
How to prevent a sore throat after hours of presenting ppt ?
"press F1 for solution", "press
shift
+F1 for urgent solution"
Need a bit of Powershell? How about
this
Who am I ?
Sometimes this is me
but
most of the time this is me
Post #1051618
L' Eomot Inversé
L' Eomot Inversé
Posted Friday, January 21, 2011 11:31 AM
SSCertifiable
Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 7,110,
Visits: 7,184
Steve Jones - SSC Editor (1/20/2011)
The NULL mistake is that people often write
where a.col = null
instead of
where a.col is null
The multi-row trigger is the same. Developers assume triggers fire once per row, instead of once per transaction. I have examples of why this is an issue.
So the common mistake is that some dim spark writes a single row trigger when a multiple row trigger is needed. That would make me list single row triggers as a common mistake, not multi-row triggers; do you really think it makes multi-row triggers a mistake?
Tom
Is minic a gheibheann béal oscailte dorn dúnta.
Is minig a cheapas beul fosgailte dòrn dùinte.
Post #1051735
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Friday, January 21, 2011 11:55 AM
SSC-Dedicated
Group: Administrators
Last Login: Yesterday @ 3:30 PM
Points: 31,436,
Visits: 13,751
Good point. I'll change the wording to say what the mistake is. Do you think
- writing single row triggers
or
- not coding triggers for multiple rows
is better?
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #1051745
Michael Valentine Jones
Michael Valentine Jones
Posted Friday, January 21, 2011 12:57 PM
SSCrazy
Group: General Forum Members
Last Login: Yesterday @ 10:43 AM
Points: 2,945,
Visits: 10,517
I think the big mistake that beginners make with triggers is using them at all. They see them as a sort of event driven solution, and don't really understand the implications.
Triggers are kind of a bad practice of first choice for beginners, while experienced developers avoid them whenever possible.
Post #1051779
L' Eomot Inversé
L' Eomot Inversé
Posted Friday, January 21, 2011 1:25 PM
SSCertifiable
Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 7,110,
Visits: 7,184
Steve Jones - SSC Editor (1/21/2011)
Good point. I'll change the wording to say what the mistake is. Do you think
- writing single row triggers
or
- not coding triggers for multiple rows
is better?
I think "not coding triggers for multiple rows" is probably best.
Also, Michael Valentine Jones has a point about people using triggers when they are not the right thing to use.
Tom
Is minic a gheibheann béal oscailte dorn dúnta.
Is minig a cheapas beul fosgailte dòrn dùinte.
Post #1051799
ALZDBA
ALZDBA
Posted Saturday, January 22, 2011 4:55 AM
SSCertifiable
Group: General Forum Members
Last Login: Wednesday, May 22, 2013 2:17 AM
Points: 6,862,
Visits: 8,049
Michael Valentine Jones (1/21/2011)
I think the big mistake that beginners make with triggers is using them at all. They see them as a sort of event driven solution, and don't really understand the implications.
Triggers are kind of a bad practice of first choice for beginners, while experienced developers avoid them whenever possible.
Very good point !
other common caveats:
- sending mails form triggers
- forgetting triggers are in-transaction and complaining when rollbacks occur
- triggers doing xp_cmdshell stuff
- how about doing some clr stuff in triggers, please use a web service to add some data ... making it depending on stuff you cannot control
Johan
Jul 13
Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere
-
How to post Performance Problems
-
How to post data/code to get the best help
-
How to prevent a sore throat after hours of presenting ppt ?
"press F1 for solution", "press
shift
+F1 for urgent solution"
Need a bit of Powershell? How about
this
Who am I ?
Sometimes this is me
but
most of the time this is me
Post #1051942
« Prev Topic
|
Next Topic »
40 posts, Page 2 of 4
««
1
2
3
4
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.