BIT Conversions

  • One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

    (The only thing that I can think of is to have bolded the "as a true / 1 value".)

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Jan.Sundbye (8/14/2012)


    Good one. Once again I fell right into the trap. Must remember to RTFQ / RTFS (Read the **** Question / Statement)

    Jan,

    I was trying to not have a "trap". What about this question do you consider to have been a trap? (I'm trying to get better at writing these QotD's).

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Dana Medley (8/14/2012)


    I almost fell prey to the wording of the question, but after reading it twice I realized my original answers were incorrect. Thank you for the great question.

    Dana,

    I'm curious about the "I almost fell prey to the wording of the question" - what was there in this question that got you feeling this way? (I'm trying to get better at writing these QotD's).

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Nice question!

  • WayneS (8/14/2012)


    One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

    (The only thing that I can think of is to have bolded the "as a true / 1 value".)

    Hi Wayne,

    I see nothing wrong with this question. As long as you take the time to read the entire question, I fail to see how one could misunderstand it.

    Maybe people who misread the question were only flying over the text and making assumptions on what the question is?


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Hugo Kornelis (8/14/2012)


    WayneS (8/14/2012)


    One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

    (The only thing that I can think of is to have bolded the "as a true / 1 value".)

    Hi Wayne,

    I see nothing wrong with this question. As long as you take the time to read the entire question, I fail to see how one could misunderstand it.

    Maybe people who misread the question were only flying over the text and making assumptions on what the question is?

    That is exactly what I was aiming for. Thanks Hugo

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

    (The only thing that I can think of is to have bolded the "as a true / 1 value".)

    Wayne

    Might I suggest that it would have been clearer for myself, and maybe for others, if the wording was:

    "How many of these values will be inserted as a 1 into the BitVal column ?"

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Hugo Kornelis (8/14/2012)


    WayneS (8/14/2012)


    One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

    (The only thing that I can think of is to have bolded the "as a true / 1 value".)

    Hi Wayne,

    I see nothing wrong with this question. As long as you take the time to read the entire question, I fail to see how one could misunderstand it.

    Maybe people who misread the question were only flying over the text and making assumptions on what the question is?

    +1

    Definitely nothing wrong, no trick, no ambiguity, and absolutely straightforward wording.

    Tom

  • I have to agree that this was a great question and don't see how it could be interpreted any other way. I think the "trap" may have been people knowing how the bit data type behaves in SQL Server and reading only what they wanted to read in the question. I'll admit, I saw it was a bit data type then read "which of the following values will be inserted" and almost went directly to answering without finishing the question since I was familiar with bit conversions. Fortunately I stopped myself, read the ENTIRE question, then answered.

  • Easy question as I had to face it in my programming some time ago!

    Thanks!

  • L' Eomot Inversé (8/14/2012)


    Hugo Kornelis (8/14/2012)


    WayneS (8/14/2012)


    One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

    (The only thing that I can think of is to have bolded the "as a true / 1 value".)

    Hi Wayne,

    I see nothing wrong with this question. As long as you take the time to read the entire question, I fail to see how one could misunderstand it.

    Maybe people who misread the question were only flying over the text and making assumptions on what the question is?

    +1

    Definitely nothing wrong, no trick, no ambiguity, and absolutely straightforward wording.

    I also agree there is nothing wrong with it. We must read and analyze the question.

    Great question, Wayne!!

    "El" Jerry.

    "A watt of Ottawa" - Gerardo Galvan

    To better understand your help request, please follow these best practices.[/url]

  • Good job Wayne - good question.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thomas Abraham (8/14/2012)


    Excellent question. I particularly like questions, like this one, that highlight areas where the behavior is not as one might think, or is different than you might find in other languages. These are the gotchas that you have to know. Thanks!

    Agreed. SQL syntax is essentially old C syntax - 0 is false, nonzero is true.

  • in correct answer -1,1 is correct

    but how 25 is correct

    means to say... in bit datatype how we can store 25 (2 digit) value

    ??????

  • buntyteg (8/14/2012)


    means to say... in bit datatype how we can store 25 (2 digit) value

    No. Any value other than 0 is converted to 1. So 1 is stored as given, and both -1 and 25 are converted to 1. (Which, by some tools, is interpreted and shown as true).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

Viewing 15 posts - 16 through 30 (of 34 total)

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