I recently spent more time than I’d care to admit troubleshooting a T-SQL query that seemed to run fine most of the time but occasionally returned an error that, on the surface, didn’t make any sense. As I ruled out several of the more obvious possible causes, the error became one of those things that make you go “hmmm”:
After considering and discarding ever more esoteric possibilities, I finally discovered the source of the error. It was one of many hidden “gotchas” in SQL Server’s inner workings, those things that, once you spot them, make you go “d’oh!”:
After I recovered from my facepalm-induced concussion, I realized that my experience might save some poor SQL Server developer or DBA from a similar fate at the hands of these bedeviling bugaboos. Over the next few weeks, I’ll be writing a series of posts on this “Things That Make You Go “D’oh!”, explaining how to anticipate some of these common pitfalls, recognize their tell-tale signs, and solve the problems they create. Hopefully, this information will help reduce the incidence of facepalm injuries among SQL Server professionals everywhere!