Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
CXXXV
Starting Member
12 Posts |
Posted - 2009-07-31 : 16:00:41
|
I have a field called GROUPS(INT) that is storing the INT equivalent of a Binary.What is the syntax to write SQL where clause to test if the 4 bit is True for instance?This doesn't work in MSSQL:SELECT * FROM membersWHERE (groups & 0x02) > 0 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-07-31 : 16:24:00
|
Seems pretty close, but that'll check the 2 bit no?DECLARE @Table TABLE (Val INT)INSERT @TableSELECT 1UNION ALL SELECT 2UNION ALL SELECT 4UNION ALL SELECT 6UNION ALL SELECT 8UNION ALL SELECT 12UNION ALL SELECT 16UNION ALL SELECT 32SELECT *FROM @TableWHERE Val & 4 > 0SELECT * FROM @TableWHERE (Val & 0x04) > 0 |
 |
|
|
|
|
|