Case Statement Update

  • Comments posted to this topic are about the item Case Statement Update

    ----------------------------------------------------

  • This was removed by the editor as SPAM

  • Very good question. I got it wrong, because I couldn't (apparently) read this early in the morning 🙂

    But a very good example of where inexperienced developers tend to get things wrong with CASE.

    Sql Server blog: http://www.tsql.nu

  • Glad to see my brain is still working, even after waiting 2 hours for my flight, with another 4 to go! I was pretty sure it had given up when it saw the delays board >_<

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Depends which column you're looking at, could be 1 and 3, or one of the options you listed 😀

    Ignore me - have contracted the plague overnight so my head isn't really working hehe - good question, never really had to use the syntax so learnt something new 🙂

  • Good one, which I'd have got correct if I'd remembered to read the title of the question!

  • I had to read it twice because I was looking for the trick. Nice, straightforward question. Thanks.

  • Good question - and apparently not all that easy since 45% of us got it wrong.

    Thanks.

  • Good question, thanks.

  • Interesting - thank you!

  • Ed Wagner (11/1/2016)


    I had to read it twice because I was looking for the trick. Nice, straightforward question. Thanks.

    Thanks Ed. No tricks, though it is the day after Halloween :-). Simply highlighting a situation one might encounter in the normal SQL world.

    ----------------------------------------------------

  • Somehow completely missed that the data type was bit.

    Moar caffeine needed!

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

  • Koen Verbeeck (11/8/2016)


    Somehow completely missed that the data type was bit.

    Moar caffeine needed!

    Ok maybe the defaulting of the bit field to 'false' is a little "bit" tricky. Part of the whole question is showing that this is possible and to look out for these things 🙂

    ----------------------------------------------------

  • MMartin1 (11/8/2016)


    Koen Verbeeck (11/8/2016)


    Somehow completely missed that the data type was bit.

    Moar caffeine needed!

    Ok maybe the defaulting of the bit field to 'false' is a little "bit" tricky. Part of the whole question is showing that this is possible and to look out for these things 🙂

    No, that wasn't tricky really, as defaults only take effect when an insert or update doesn't specify the content of the column, and here the content is specified because the case statement provides content for that column in every row affected by the update, so the only question is what content does the case statement provide for the columns of interest.

    Unless, of course, someone imagines that a default constraint substitutes the default value for a specified NULL, which is about on a par with failing Jeff's favourite interview question.

    Tom

  • ...Case Statement Update...

    Shouldn't that say "case EXPRESSION update"?

    ...One of the symptoms of an approaching nervous breakdown is the belief that ones work is terribly important.... Bertrand Russell

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

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