THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Adam Machanic

Adam Machanic, Boston-based SQL Server developer, shares his experiences with programming, monitoring, and performance tuning SQL Server. And the occasional battle with the query optimizer.

Invitation for T-SQL Tuesday #002: A Puzzling Situation

Welcome to the second installment of T-SQL Tuesday, the monthly SQL Server blog party! Last month's kickoff event was a great success, and I'm really excited for this month's theme. I hope that we see even more bloggers, with even more great posts this time around--so please spread the word!



Have you ever found yourself unable to figure out the intricacies of how some piece of code works? Ever been confused by the results you've gotten back from a query, only to find out that something totally unrelated was going on? Or have you ever been compelled to wile away your spare time working on a "challenge" posted by some blogger?

For this month's T-SQL Tuesday, I'm asking participants to write a blog post on a "puzzling" topic, along the lines of some of the following ideas:

  • Describe a confusing situation you encountered, and explain how you debugged the problem and what the resolution was
  • Show a piece of code that doesn't behave as most people might expect, and illustrate the reasoning behind the discrepancy
  • Create a challenge for your readers to solve
As always, even given the event's name the posts are not limited to T-SQL! Any component of, or software product related to SQL Server, is fair game. MDX, SSIS, LINQ to SQL, Entity Data Model, NHibernate, and any other software product that deals with SQL Server data can be featured in your post. Be creative!



As before, any blogger can--and should--feel free to participate in this event. In order to make the event slightly more international, I'm changing the time range from PST-based to UTC-based. So the rules are:

  • Your post must go live between 00:00:00 UTC and 23:59:00 UTC on Tuesday, January 12, 2010
  • Your post must link back to this one, and it's recommended that you clearly identify the post as a T-SQL Tuesday post
  • You are responsible for ensuring that a trackback or comment appears here so that I can find the posts

Follow the rules, and your post will be included in the roundup to be posted on January 13 or 14. Don't follow the rules, and it won't show up there. Simple as that!



Follow the event on Twitter by watching for the #TSQL2sDay hash tag.


Additional Notes

If you put in a comment and your post doesn't follow the other rules, I will ignore your post. (Really sorry to have to add this, but a couple of people felt the need to do that last time and it violates the spirit of the event. Especially the person who tried to spoof a trackback, without any kind of link in the initiating post. If you're not going to link back to the invitation post, please don't bother participating, now or ever.)

Per the rules outlined last time, I'm hosting again this month, and starting next month the event will rotate around to other blogs. I'll control the schedule even once the event leaves here, so please let me know if you're interested in hosting--either with a comment, a Twitter DM, or an e-mail--and I'll add you to the list. To host, you must have participated in two previous T-SQL Tuesday events, and your blog must have had at least one post a month for the prior six months.

I'm also collecting topic ideas, and would appreciate your sending them over as you think of them so that we can ensure that we have plenty of material to keep this event running for years to come.

Enjoy, and as always let me know if you have comments, questions, concerns, etc.

Published Monday, January 4, 2010 11:30 AM by Adam Machanic



mjswart said:

Sounds awesome, can't wait!

January 4, 2010 11:23 AM

Rob Farley said:

Written mine already - hopefully the trackbacks will appear on schedule, since I'm unlikely to be online next Tuesday.

January 4, 2010 7:43 PM

David Leibowitz said:

Packaged up and scheduled for Tuesday.

January 9, 2010 2:39 PM

Michael Coles: Sergeant SQL said:

On the SQL Server public programming newsgroup someone recently posted a question about an SSMS error

January 10, 2010 2:16 PM

Mike C said:

Missed the last one (doh!), couldn't wait to jump into this one :)

January 10, 2010 2:20 PM

Adam Machanic said:

I guess you jumped in a bit early? I hope you have another post for Tuesday!

January 10, 2010 3:36 PM

Rob Farley said:

January 11, 2010 7:55 PM

Kalen Delaney said:

It's time for the second T-SQL Tuesday , once again managed by Adam Machanic. Since my first T-SQL Tuesday

January 11, 2010 7:59 PM

Kalen Delaney said:

It's time for the second T-SQL Tuesday , once again managed by Adam Machanic. Since my first T-SQL Tuesday

January 11, 2010 8:03 PM

The Rambling DBA: Jonathan Kehayias said:

Every couple of weeks on one of the forums someone will ask a question about how to restore a backup

January 11, 2010 10:53 PM

The Rambling DBA: Jonathan Kehayias said:

This week I have two posts for TSQL2sday .  Initially I wrote my first blog post , but as luck would

January 11, 2010 11:26 PM

Michael Coles: Sergeant SQL said:

Ahhh, attention to detail. I misread Adam's T-SQL Tuesday rules and posted early. So here I go again

January 12, 2010 12:31 AM

Mike C said:

Yeah I was so excited I hit the publish button too quick.  Rather than just republish that one I went ahead and wrote up another one :)

January 12, 2010 12:33 AM

NULLgarity said:

A "SET FMTONLY ON" puzzle for T-SQL Tuesday #002.

January 12, 2010 7:30 AM

tanoshimi said:

January 12, 2010 7:49 AM

Alexander Kuznetsov said:

Neither UPDATE … IF (@@ROWCOUNT = 0) INSERT nor IF EXISTS(...) UPDATE ELSE INSERT patterns work as expected

January 12, 2010 9:58 AM

Alexander Kuznetsov said:

January 12, 2010 10:04 AM

Brad Schulz said:

I don't know why, but T-SQL Tuesday always inspires me to write something completely zany:


January 12, 2010 12:46 PM

Rob Farley said:

The solution for my puzzle is at

I look forward to reading all the Tuesday posts soon - particularly learning about Brad's trolls!

January 12, 2010 4:33 PM

Adam Machanic said:

The query optimizer is a finicky thing , and sometimes it doesn't understand exactly what you're trying

January 12, 2010 5:23 PM

Rob Farley said:

Earlier today you may have seen a blog post of mine about a puzzle involving HAVING . You should read

February 20, 2010 2:21 AM

Adam Machanic said:

Just over a year ago I kicked off T-SQL Tuesday , "a recurring, revolving blog party." The idea was simple:

December 7, 2010 1:43 PM
New Comments to this post are disabled

About Adam Machanic

Adam Machanic is a Boston-based SQL Server developer, writer, and speaker. He focuses on large-scale data warehouse performance and development, and is author of the award-winning SQL Server monitoring stored procedure, sp_WhoIsActive. Adam has written for numerous web sites and magazines, including SQLblog, Simple Talk, Search SQL Server, SQL Server Professional, CoDe, and VSJ. He has also contributed to several books on SQL Server, including "SQL Server 2008 Internals" (Microsoft Press, 2009) and "Expert SQL Server 2005 Development" (Apress, 2007). Adam regularly speaks at conferences and training events on a variety of SQL Server topics. He is a Microsoft Most Valuable Professional (MVP) for SQL Server, a Microsoft Certified IT Professional (MCITP), and an alumnus of the INETA North American Speakers Bureau.

This Blog


Privacy Statement