SQL Problem solved, it wasn't weird, but the responses were

It's always crazy when you post a question to your blog or a forum when you get everything but what you expected as responses. This happened with my SQL "problem" last night.

First the good news. There was no problem. If you look at the sproc I had, I was sorting correctly when I populated the cursor, but not in the join at the end. Whoops! Can't believe no one caught that.

Anyway, one person came in and said you couldn't sort by a bit field. That obviously wasn't true because I was clearly doing it before. When someone called him on it, he said it wasn't ANSI standard and you should avoid it. Should we avoid using the CLR in SQL 2005 too? It's not ANSI standard. Sometimes I just don't understand how people respond.

Another respondant said using a cursor was a bad idea in his experience, but didn't offer an alternative. The article I linked to makes a pretty strong case for using a cursor to page data. In fact, I searched far and wide on the Web and Usenet to find some kind of quantitative reasoning for this approach, and it's the only one I found. Hey, I'm easily influenced, especially in areas for which I have no significant expertise (like SQL). Show me something better and I'll switch to that. In running this sproc against 30,000 forum topics, it's pretty fast. If I apply a little caching to it, I suspect it will be even faster.

Regardless of the outcome, I love to see people get out there and debate stuff like this. A disadvantage of working alone as your own business is that you otherwise don't have another set of eyeballs to question your work.


  • To spur a little bit more, BIT data type somehow was in SQL-99 Standard as Boolean :D

  • "Can't believe no one caught that."

    ...and we can't believe you didn't catch it. After all, it's not our code. Or, did you think that we all work for you?

    "Should we avoid using the CLR in SQL 2005 too? It's not ANSI standard. "

    It's all relative my friend. There are times when you might want to stick with the ANSI standard. Never say never, so advising someone to never sort on a bit field is short-sighted. However, saying that ignoring ANSI standards is perfectly OK just because SQL 2005 does is equally as absurd. Everything in it's context.

  • Relax dude... why are you taking it personally? No one said ignoring ANSI standards are OK.

Comments have been disabled for this content.