I'm working on a new app with Sql CE and before I got too deep in DB design, I wanted to make sure that it can support a bitmask query.
What I want is a bit-packed field to handle support for region. So I'd like to be able to take a field (e.,g. [Support]) and do a bitwise and with the current region code and see if it is supported.
I know I could get all the data and write a method to make it work, but was hoping there would be some way to construct a query to only pull down the relevant information.
Thanks
Something like this ?
Code Snippet
CREATE TABLE test (
[id] [int] NULL,
[bitwise] [int] NULL
)
INSERT INTO Test (id, bitwise) VALUES (1, 7)
INSERT INTO Test (id, bitwise) VALUES (2, 1)
INSERT INTO Test (id, bitwise) VALUES (3, 0)
select * FROM test WHERE (bitwise & 1) = 1
(returns 2 rows)
|||That should do it. I thought it would be something similar to that. I just couldn't verify that would work with CE... maybe I need to improve my googling skills
No comments:
Post a Comment