Helping people kick bad SQL Server habits
October 10th | 2009 By
In a greedy attempt to win an interesting blogger contest, and because I see this stuff all the time when dealing with inherited code or answering questions in newsgroups or forums, I decided to put together a series of blog posts designed to help fellow SQL Server dabblers to kick some of the bad habits they’ve picked up over the years.
It actually started long before the contest, but at the time was aimed more at picking up good habits. Last year, I wrote an elaborate post detailing my own personal “best practices” checklist that I try to follow when writing stored procedures. And earlier this year, I wrote about always terminating statements with semi-colons.
It can be hard to enforce good habits; it is much easier to demonstrate why bad habits are bad, and drive positive habits simply by providing motivation to avoid the negative ones. So, the series was kicked off last week, and so far I have written sixteen “here’s why you should stop doing x” articles. There has been great feedback on the articles themselves, several discussions have launched because of them, and I’ve even spurred other people to write their own posts to complement the series.
Who knows, maybe the series will be good enough to see my name in lights at PASS. But more importantly, maybe it will help you, or someone you work with, to kick some bad habits.
Bad habits to kick : ORDER BY ordinal
Bad habits to kick : using loops to populate large tables
Bad habits to kick : using old-style JOINs
Bad habits to kick : using table aliases like (a, b, c) or (t1, t2, t3)
Bad habits to kick : declaring VARCHAR without (length)
Bad habits to kick : using dashes and spaces in entity names
Bad habits to kick : using SELECT or RETURN instead of OUTPUT
Bad habits to kick : using SELECT * / omitting the column list
Bad habits to kick : avoiding the schema prefix
Bad habits to kick : inconsistent naming conventions
Bad habits to kick : making assumptions about IDENTITY
Bad habits to kick : choosing the wrong data type
Bad habits to kick : abusing triggers
Bad habits to kick : using the visual designers
Bad habits to kick : using alias types
Bad habits to kick : mis-handling date / range queries






Pingback: Tweets that mention Helping people kick bad SQL Server habits « OTO One to One Interactive -- Topsy.com
Pingback: Aaron Bertrand : Connect digest : 2009-10-17
Pingback: Aaron Bertrand : Bad habits to kick : putting an IDENTITY column on every table
Pingback: An update of my SQL Server “Bad Habits” series « OTO One to One Interactive