DATE Conversion and Format

  • Comments posted to this topic are about the item DATE Conversion and Format

  • Easy one for me. ๐Ÿ™‚ Specially after going through all the options carefully and matching each one of them with the entries in the table. ๐Ÿ™‚

  • Nice QotD thanks

    Hope this helps...

    Ford Fairlane
    Rock and Roll Detective

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • practical questions, a good one ๐Ÿ™‚

  • Guessed it right as that was the only option seemed right & logical to me (after eliminating all other options), then ran the query just to make sure before answering.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • good question ... thanks for sharing

  • All:

    I thought I would give a nice "fun" one. I believe in the basics and you would be very surprised as to how many "experienced" DBAs (Logical and\or Physical) I know got this one wrong.

  • Technically both the "correct" answer and the answer marked "No rows returned, conversion error on query 3" are correct. It depends on how the Query Analyzer and query engine process the query. It could choose to multi-thread it and the first item it examined could have the error, thus no rows returned. Additionally, the table is a Temp Table with no indexes (Heap) and add in the fact that query returned is not garaunteed an order unless an explicit order by is stated. I have run into many instances where I tried to filter out by isdate(xyz) = 1 only to have the query fail because it didn't process in the order I thought it should.

  • Nice QotD. The '41' was a big clue. Thanks and keep them coming.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • argh...not enough sleep lately and definitely not enough coffee!

  • Not a really bad query, but not really good either. It's fallen into the trap of assuming that the order in which rows in the heap are scanned is fixed, as pointed out by Venoym. It's also a bit cluttered - rather a lot of complexity to discover that 41 is not between 1 and 12 inclusive, most of that select statement is pure distraction.

    Tom

  • steve.jacobs (10/30/2013)


    I believe in the basics and you would be very surprised as to how many "experienced" DBAs (Logical and\or Physical) I know got this one wrong.

    I'm not surprised. How many people use varchar columns to hold dates?

  • L' Eomot Inversรฉ (10/30/2013)


    Not a really bad query, but not really good either. It's fallen into the trap of assuming that the order in which rows in the heap are scanned is fixed, as pointed out by Venoym. It's also a bit cluttered - rather a lot of complexity to discover that 41 is not between 1 and 12 inclusive, most of that select statement is pure distraction.

    Very true. However, this is just a small example of the bad query design I have inherited. I wanted to show a small example of what I deal with everyday from our legacy systems. But still fun to try to figure out "bad" query results.

  • Nice question...

    Manik
    You cannot get to the top by sitting on your bottom.

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply