• DB.Duck (9/17/2012)


    CELKO (9/9/2012)


    ...we do not use BIT flags in SQL...

    You, sir, couldn't be more wrong. That is all.

    Actually it's almost a great point but poorly stated. Let me give this a shot. For the most part you should avoid bit flags.

    Often they are used to replicate data. Case in point is the [TerminationDate] of an employee. That column will be NULL for everyone who is still working and have a valid date for folks who have, or were, terminated. Therefore a [Terminated] bit column is not needed.

    Then there is the whole aspect of indexing on bits. SQL Server is a quite fine product (all software has bugs so don't start) but even the greatest software has to make compromises. Indexing on a bit suffers. I'll leave further reading to you. There are many good articles and books.

    Bits are tempting. Recent versions will cram 8 bits into one byte of actual storage. Sounds cool. You create the first one at design time. You are sucked into a false sense as adding the next seven are very fast (only the meta data is changed). Now you add the ninth and wait as every page in your table is rewritten.

    ATBCharles Kincaid