• Jeff Moden (4/9/2012)


    I don't know why someone rated this as a "3" at the start. It's a good primer on Boolean Logic even if someone doesn't use the function. Nicely done.

    I can't say for sure (because it wasn't me) but one guess might be that stuffing bits in this way is pretty widely regarded as an anti-pattern for SQL Server coding. It's a different story in compiled languages (such as .NET) of course, but bit-stuffing is hard to reconcile with relational principles (most would regard a bit-stuffed column as violating first normal form) and, as a consequence, does not work well with the SQL Server in general, and the query optimizer in particular (which is also based on relational principles). As an example, consider the statistics on a bit-stuffed column! Wrapping the whole thing in a scalar UDF (the very worst kind) may also have been a factor in the low rating.