What I am currently know is that use bitwise and Int type to store multiple selection value in Database.
Take Sql Server 2008 as a example, ‘Int’ type in sql server is 32bit, so it accepts 32 answer, I only can use 1,2,4,8,16, etc to represent the answer, due to I need to store the multiple selection into one value, and use bitwise operation to separate them.
Int: -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)
BigInt: -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
No mater Int or BigInt, the number of answer is till have a limit (32 or 64 or 128).
So is there any other way to deal this situation?
Many thanks.
It’s probably a lot easier to store these using the bit data type in SQL Server. MSSQL will compress multiple bit columns into bytes containing up to 8 bits. For example, if you have 9 bit columns, it will take up 2 bytes total.
But if you have a really large number of bits, then it will just make for poor database design to break them out into separate columns in which case perhaps you can use a fixed-length binary data type which you can access as a byte array in .NET or VB.