Critique - Common SQL Server Mistakes

  • This is a presentation that I have been working on and evolving at a few user groups. Is this abstract ok?

    Abstract: This presentation looks at a number of common mistakes that people make in SQL Server. There are edge cases where these might not apply, but for the most part, these are mistakes that you do not want to repeat as you are building applications on the SQL Server platform.

    The basic agenda:

    * SELECT *

    * Shrinking databases

    * GUID as a Clustered Key

    * Functions in the WHERE Clause

    * IS NULL

    * Multi-row triggers

    * Indexing all Columns

    * Cursors

    * SA Account Usage

  • I would add Schema qualifiers, Query Hints and Interleaving of DML and DDL

    -Roy

  • with(nolock)

    'nuff said.

    - 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

  • I am planning to write a controversial Blog regarding NO LOCK. 😀 I think you will broil me over red hot charcoal once I am done with it... 😀

    -Roy

  • Roy Ernest (1/20/2011)


    I am planning to write a controversial Blog regarding NO LOCK. 😀 I think you will broil me over red hot charcoal once I am done with it... 😀

    Nah.

    Slow cooking is much better....

    - 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

  • Good feedback on this, however I'm more wondering if you think the abstract is well written. Does it make you want to go, or not go, to the session?

  • It looks a little too basic for me. I'd be more likely to present on that subject than to be on the receiving end of it.

    Edit: Might want to fix the spelling on this thread too.

    - 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

  • You could expand with more on database design:

    Failure to normalize

    No primary keys or unique constraints

    Inappropriate data types

    Failing to define columns as not null

    No foreign keys or DRI

    No check constraints

    Many problems are built into applications at the database design stage and turn the application into a giant mess of hacks to work around design failures.

  • - Books online. and how to get there the easy way .

    (highlight your keyword and hit shift+F1)

    - point to "when using the query designer, this is how you assign table aliasses" !

    - The importance of foreign keys, not only for data reliability, but how SQLServer actually will use this in your advantage. Grant has a great demo on that !! http://www.scarydba.com/2010/11/22/do-foreign-key-constraints-help-performance/

    It is really an eye opener for most of my devs.

    - chose a clustering index

    - by default, index your foreign keys

    - you need database maintenance !

    - what's a sql cluster

    - what's a DRP/backup/data loss

    - how big will your table / database be at start, in 1 month, in 3 months, in 6 months,...

    - consult your dba

    However, if you overload, you'll just be another nagging pita dba 😉

    and the message is lost in a black hole 🙁

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - 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

  • 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? :blush:

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • 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

  • 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.

  • 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 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • 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? :blush:

    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

  • - 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

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - 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

Viewing 15 posts - 1 through 15 (of 39 total)

You must be logged in to reply to this topic. Login to reply