• GilaMonster (9/12/2010)


    Lennie (9/11/2010)


    GilaMonster (9/11/2010)


    A bit is a numeric data type that stores just two possible numeric, 0 and 1. Those are the mathematical numbers and have no special meaning.

    😎

    I was asking what the the meaning of BIT value 1 and BIT value of 0 ? Does value 0 (zero) means YES or YES and

    Does value 1 (one) means NO or FALSE ?

    Up to you.

    Intrinsically in SQL 0 means just 0 and 1 means just 1. It's a bit column, not a boolean. You can assign true/false meanings to the values as you like. It's not MS-Access where the boolean column has such meanings (0 true and 1 false)

    Typically, if people do assign such logical meanings to the 1 and 0, 1 is true and 0 false, but it's totally up to you.

    Your point about Access is why it is so important to understand that while, as Paul White says

    You can assign the string values 'true' and 'false' to a bit data type. 'True' will be stored as 1, and 'False' will be stored as 0. (2005 and later only)

    By convention, a bit value of 1 is associated with a boolean 'true', and 0 with a boolean 'false'. As Gail points out, this isn't enforced by SQL Server (except by implication as noted in the string assignments above), but it is extremely common.

    Most people would see a bit value of 1 as implying 'true', 'on', 'yes' or some other equally 'positive' interpretation. A bit value of 0 is seen as implying 'false', 'off', or 'no'.

    this won't always be the case. If you're dealing with a table that someone else designed and they were primarily an Access developer before creating this database or if the database was "upsized" to SQL Server from an Access database, then 0 could easily be "true" and 1 would be "false".

    This could also be the case if the specs for the database comes from a picky programmer or a business person with no tech experience.

    You also have to remember that a bit field can be declared as accepting NULL values. This can complicate matters if the original designer considers NULL a default position and instead of meaning "unknown" it could mean either "true" OR "false".

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams