I show some tricks for getting row counts efficiently, and explain why an accurate row count for a large table is a pipe dream.
Category: Bad Habits & Best Practices
I repeat "Bad habits" advice from the past about using statement terminators and schema references to avoid debugging troubles.
I point out that an often-used connection setting, AttachDBFileName, may be the source of many wasted hours of debugging and troubleshooting.
I treat a common scenario: behavior differs between two SQL Server databases that may be the same version, but different compatibility levels.
I discuss the NOLOCK hint in SQL Server, and why you want to avoid slapping it onto every table mentioned in every query.
I discuss ten common cases of misplaced optimization.
I explain why you should avoid helper functions, and join against the catalog views instead.
I provide links to presentations (one with colleague Kevin Kline) at SQL Bits XII.
Last Thursday I presented my "Bad Habits to Kick" presentation at the New England SQL User Group; attached is the slide deck.
By way of an example, see why most of what you hear about SQL Server is only true some of the time, at best.
I see a lot of people suggest while loops instead of cursors in situations where row-based processing is required (or, at least, where folks think that row-based processing is required). Sometimes the justification is...
See why I prefer
alias = expression over the more standards-compliant
expression AS alias syntax.
See several examples supporting the idea that you should use catalog views, not INFORMATION_SCHEMA, in SQL Server.
Learn why you shouldn't use BETWEEN for date range queries, even with the date data type.
Read about some date/time shorthand you should avoid.
See why you should use sp_executesql instead of EXEC() for running dynamic SQL strings.
See an example that defies a generalization about performance of getting the largest value in a column.
In Boston today I presented my "Bad Habits to Kick" deck to 66 people. You can download the deck and samples from the SQLSaturday web site or directly from http://bit.ly/AB-71-Slides. Like the Chicago event,...
Your naming scheme isn't important, but being consistent is crucial.
In my last post in this series, I talked about problems associated with creating (and using) what I call the "uber-view." This time, in line with tomorrow's T-SQL Tuesday hosted by Mike Walsh, I...
In my last post in this series, I talked about using ancient copies of Books Online, and why it can be important to keep your local documentation current. This time I wanted to touch...