• Hi Adrian,

    Try to visualize a life without bitmasks instead.....

    Remember the rules for first normal form - every column should only hold atomic values. Clearly, a bit mask violates that rule. If you want to store 8 yes/no values, use 8 columns instead. Define them as bit, if you must (I am not as opposed to the bit datatype as some, but not a big supporter either), and SQL Server will still use only 1 byte to store them. Or store them as CHAR(1) with a CHECK constraint to limit the population to 'Y' of 'N', and gain a lot of clarity at the price a mere 7 extra bytes.


    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/