The first presentation, likely to extend over three or four lunch sessions, is entitled "20 Ways To Abuse T-SQL". This presentation introduces the twenty most common mistakes, best-practice violations, and general "no-no's" that I've seen as a DBA, within this company and others prior.
As a spin-off of that presentation, I'm starting a series of blog postings, sharing the same title. I'll try to post, at minimum, one item a week. The full list of twenty items is listed below, I'll update this list with links to the actual posts as they're published.
20 Ways To Abuse T-SQL
- Procedural thinking vs set-based
- SELECT * (performance implications, dangers of using in a view)
- COUNT() vs EXISTS()
- Non-SARGable filtering (functions around columns, exclusionary filters <>, NOT IN)
- Improper sort ordering (using ORDER BY when row order is irrelevant, not using ORDER BY and assuming a default sort order)
- Failing to review the query plan
- Incorrect or mismatched data types (implicit conversions, comparing numeric to character, casting dates to strings)
- Reassigning a variable from a query (without first setting it to NULL)
- Failing to qualify object names
- Subquery gotchas (unqualified column names, performance, NULLs, multiple rows)
- Lack of error handling (transactions, TRY/CATCH)
- Assumptions about predicate processing order (key/value tables, cast/convert plus check of data type)
- Incorrect placement of predicates (WHERE vs ON in a LEFT JOIN)
- Misuse of user-defined functions
- Designing triggers for single-row operations
- Using @@IDENTITY instead of SCOPE_IDENTITY()
- Underestimating production data volume and workload (ran fine in Development database, runs for hours in Production)
- Relying on old techniques, not utilizing new language features (CTE’s, INTERSECT/EXCEPT, OUTPUT)
- Overlooking stored procedures for complex queries (when/why to use, advantages/disadvantages)
- Ignoring industry best practices and DBA recommendations, lack of or misunderstanding of database concepts

Nice List! I could not think if anything else.
ReplyDeleteBut, I need these posts NOW ;-)
ReplyDeleteThanks Joe. Some of these could almost be multiple topics, but I wanted to keep the list at a round number.
ReplyDeleteStay tuned, they're coming!
ReplyDelete