Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL bit query

Status
Not open for further replies.

emueth

Programmer
Joined
Mar 27, 2001
Messages
4
Location
US
I have a Cold Fusion application with a SQL 7 database. The database has an employee table with a bit field for storing certain permissions. How do I write my sql statement to, for example, return all employees that meet the criteria of a bitand on the fourth bit? Thanks in advance for the help.
 
I assume you mean BINARY data type rather than BIT. A BIT data type in SL Server hold one BIT, allowing values of 0 or 1.

Take a look in SQL BOL for Bitwise operators.

& (Bitwise AND)
Performs a bitwise logical AND operation between two integer values.

NOTE: Bitwise operators have integer arguments so you'll need to convert your Binary column to Integer for the operation.

cast(colA as int) & 4

I hope I understood your question and this information at least gets you started.

BTW: You can access SQL BOL from the following link.

Terry Broadbent
Please review faq183-874.

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top