1

I'm designing a table to keep track of a value that has to represent the on-off setting of several hundred states. I would expand this to 512, to give room for future growth and be a power of two.

So I want a 64 byte = 512 bit column. My problem is that SqlServer bitwise operations don't support right operands larger than int, so there would be no way to access any bits past 32.

How can I handle this issue?

2

SQL Server supports up to 1,024 Columns per nonwide table. Use them. The bit data type, if declared as NOT NULL, will take one bit of storage. You can then address each state specifically by name, making for cleaner, more maintainable code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.