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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Bitwise comparison

Author  Topic 

de9625
Starting Member

17 Posts

Posted - 2004-03-23 : 12:32:58
This might not be the right forum since I need to do this against a DB2 database but hope someone could help me.

This is what I want to do:

SELECT id, flag
WHERE (integer(flag) & 8) = 8

Im not sure if this even works with SQL Server?

Any suggestions?

aiken
Aged Yak Warrior

525 Posts

Posted - 2004-03-23 : 12:35:23
select id,flag
from whatever
where (flag & 8) = 8

Though really, this is a performance nightmare because it can't take advantage of indexing, so you'll get lots of table scans. Much better to use a join table of attributes rather than trying to save the few bytes by packing them into bits, IMHO.

Cheers
-b

Go to Top of Page

de9625
Starting Member

17 Posts

Posted - 2004-03-23 : 12:37:36
I can't do much about the database.
Go to Top of Page
   

- Advertisement -