SQL replacement for CBool()

In an Access query, I was able to use the CBool() function to limit a query result as follows:
WHERE (CBool(integerA And integerB)=True)
When running this query in MS SQL, I get an error saying that CBool is not a valid inbuilt function. I am new to MS SQL and would like to know how to do this in MS SQL.
mortonkrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The SQL equivalent of Boolean is bit.

What are you trying to do here?  Test that both IntegerA and IntegerB are not null?
If so..

WHERE IntegerA IS NOT NULL AND IntegerB IS NOT NULL

Keep in mind that in SQL, 1=True and 0=False, whereas in Access -1=True and 0=False
0
mortonkrAuthor Commented:
I am checking for the presence of a bit in the integerA by doing an And of it and a bit image integerB.
Eg: integerA is 0000 1100 0010
IntegerB is 0000 0000 0010 so that if bit 1 is high, then the result will be true.
0
David ToddSenior DBACommented:
Hi,

The SQL bitwise and operator is &
http://technet.microsoft.com/en-us/library/ms174965(v=sql.90).aspx

ie
where (integerA & integerB) = integerB

HTH
  David
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mortonkrAuthor Commented:
Thanks David.....so simple! Perhaps I was trying to make it more difficult than it was!
And thanks for the SQL website reference, I now have a good reference to work with.
0
David ToddSenior DBACommented:
Hi

About the website, Its very searchable with google. MS of course would prefer me to say bing.

Once upon a time I used to religiously install the SQL bol on my workstation. I stopped putting it on developers workstations some years back, and I'm almost past using it on my workstation, and instead using the on-line copy.

As you can see, variations in sql version are managed. Unfortunately when SQL 2000 went end of life it has dropped off the bol.

Regards
  David
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.