Forum Discussion
Modelling bit fields in MS SQL
I need to create a column in a table that contains binary data. However, I need to model it down to the bit level, not the byte level. For example, I need to create a 3-bit column. I don't care if internally it is stored as 8 bits (1 byte), but I need to be able to discover from the DB that it is meant to be only 3 bits. In other words, my programmatic access will be able to operate on exactly 3 bits and discard the remaining 5 bits. The "bit" type is only 1 bit, with no option to specify a length. The "binary" type does have a length specifier, but it is in bytes, not bits.
The objective is to be able to extract data from the DB and create a representation that can be loaded into a C program that has a struct with bit fields defined. Any thoughts on how to accomplish this?