I'm trying to come up with a simple way to track a list of enabled services for customers in a 2008 MS SQL Server database.
There are 256 possible enabled services that a customer can subscribe.
For each customer I need to know which services are enabled, and which services are disabled.
I was thinking of using some sort of bitmask in sql server. I was thinking of defining the bitmask as a 32 byte binary column. That would give me 256 0 or 1's to flip on or off in one column. An enabled service would have the bit on or 1, and a disabled service would have the bit off or 0.
I would prefer to have the left most significant bit refer to Service 1, and the right most bit refer to Service 256. In other words the bits are read from left to right.
Looking for an easy way to turn on any bit in the bitmask. I've been playing with the bitwise or '|' operator.
Ideally I would write a UDF that would make it easy to turn on any bit using a decimal number to signify which bit to turn on.
For example if I want to turn on bit 110, I am looking to do something like: Bitmask = Bitmask | 110.
Spent all afternoon trying to come up with something, and searching the web, but haven't been able to pull it all together.
Any help and suggested approaches would be greatly appreciated.