Square Peg Meets Round Hole

Besides contributing at @TheDailyWTF, I write DevDisasters for Visual Studio Magazine, and involved in various side projects including child rearing and marriage.

Have you ever been faced with this scenario? You need to unscrew a Phillips head screw but you only have a similarly sized flat head screwdriver available.

I have and boy was it ever frustrating.

In the end, the screw head was a little chewed up, my wrist hurt from trying to contort my hand, my wife chided me for cursing in front of the kids (after all, I was only trying to replace the batteries in that friggin talking doll in the first place!!) - but hey - it worked!

Part of me clings onto the hope that the original author of the anonymously submitted bit of code below was in a similar situation. He or she didn't know that he had tools available to add a delay to some process. Perhaps the original dev was a loner, a rebel - writing things his way. ...but I have a strong suspicion that it's just a horrible, cruel prank being perpetrated by a rude jerk of a developer. Yep, I think that's it.

The code is completely legit. We use similar thing to get current time: "select now()" - the thing is, users can change time on their machine. Even while application is running. By using "select now()" we have always correct, server time. Same way for pauses. Do not underestimate ingeniousness of your users.

There's one thing in this story that just completely boggles my mind. What idiot decided that there should be a "WAITFOR" statement in SQL?

Given some of the problems with doing expressions in SQL, and then this, all I can say is: I really wish they would get people for SQL product designers and for the standards committee who are not BASIC programmers!

No it's not - You cannot hammer the database server in a timing loop like that without "consequences" - imaging 300 users all doing that. No "real" queries would stand a chance. This does not scale. Use Sleep(2000) or whatever your language provides.