?
Solved

SQL Bitand Operation

Posted on 2003-03-29
4
Medium Priority
?
1,602 Views
Last Modified: 2008-01-16
Hi there,

I would like to know how I can perform a
bitand operation on a Sybase database field
using an SQL statement.

I have a table and one of the fields 'flags'
requires bitand operations. If I update flags
field to be 1024 using a standard update statement
I overwrite all the other flags that have been set
(through bitand operations) for that particular record.

I would be really obliged if some one could help me out
on this one.

Thanks in advance

0
Comment
Question by:tjdos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:tjdos
ID: 8231523
I think I might have discovered the answer to my own question. I think it is:

update TableA set Flags = (Flags & 1024) where id = 1

I know the & works in select statements but I never thought of using it in an update statement.

I'll have to wait till monday to check whether this works
but anyone can confirm that I am right (or inform me if I'm wrong) before then I would appreciate it.

0
 
LVL 5

Accepted Solution

by:
amitpagarwal earned 1000 total points
ID: 8243187
your code looks good.
0
 

Author Comment

by:tjdos
ID: 8259699
I have discovered the actual answer to this question:

update TableA set flags = flags | 1024 where id = 1

My first solution was actually incorrect as all it did was update the field to 0 or 1 depending on whether 1024 flag had been set or not through a bitand operation.
0
 

Author Comment

by:tjdos
ID: 8322216
Today's your lucky day!!

Hi there. Your answer didn't really help but I think I need to award these points to someone or else they'll just be hanging there with nobody able to use them.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question