bitwise operation questions

From: Craig Buchanan (someone_at_somewhere.com)
Date: 02/26/04


Date: Thu, 26 Feb 2004 16:02:16 -0600

I would like to store mailing-list preferences in an Int field using bitwise
operators, but I'm having a bit of difficultly. The field is named
'EmailFlags'. The values for the lists are: 1=ListA, 2=ListB and 4=ListC.

Questions:

1). If I want to set the preference value to include listb and listc, how
do I contruct the SQL?

UPDATE table
SET EmailFlags= 2 | 4

2). If I want to get a list of rows that are on list B and C, how do I
construct the SQL?

SELECT *
FROM table
WHERE EmailFlags = 2 or 4

3). If I want to remove listB from a given row, without eliminating the
other flags, how do I construct the SQL?

UPDATE Table
SET EmailFlags = ???
WHERE Id=...

Thanks,

Craig Buchanan



Relevant Pages

  • Re: Creating Tables
    ... Connected Innovation ... > different from sql server. ... > for example i can't specify the length of the field and the data types ... > have changed, no varchar but ntext instead, there's also the int field. ...
    (microsoft.public.sqlserver.ce)
  • Re: Scope_Identity returning Decimal for an Integer field
    ... Hitchhiker's Guide to Visual Studio and SQL Server ... "Armin Zingler" wrote in message ... The field is an int field, but after INSERTing, select @@identity returns a Decimal value. ...
    (microsoft.public.dotnet.framework.adonet)