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
 Transact-SQL (2000)
 Bitwise Ands with Bigint

Author  Topic 

dcwebman
Starting Member

11 Posts

Posted - 2005-08-19 : 12:22:41
We are using MS SQL 2000 and came across a limitation. Apparently a bitwise & comparison can only use up to Int. Trying it with a larger number fails.
For example:
declare @FieldMask bigint
set @FieldMask = 4294967296
select 4294967296 & @FieldMask

Or trying this too:
declare @FieldMask bigint, @FieldMask2 bitint
set @FieldMask = 4294967296
set @FieldMask2 = 4294967296
select @FieldMask2 & @FieldMask

Is there any way to use a bigint value with the & comparison?
Thanks,
Jeff

Kristen
Test

22859 Posts

Posted - 2005-08-19 : 13:46:06
Hi dcwebman, Welcome to SQL Team!

From BoL it looks like there aren't any bitwise operators on BigInts

quote:

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

Syntax
expression & expression

Arguments
expression

Is any valid Microsoft® SQL Server™ expression of any of the data types of the integer data type category. expression is an integer parameter that is treated and transformed into a binary number for the bitwise operation.


Kristen
Go to Top of Page

VladRUS.ca
Starting Member

23 Posts

Posted - 2005-08-19 : 13:51:34
@FieldMask2 bitint ???

Try this code (works fine for me):
==================================
declare @FieldMask bigint, @FieldMask2 bigint
set @FieldMask = 4294967296
set @FieldMask2 = 4294967296
select @FieldMask2 & @FieldMask

OR
declare @FieldMask bigint, @FieldMask2 bigint
set @FieldMask = 9223372036854775807
set @FieldMask2 = 9223372036854775807
select @FieldMask2 & @FieldMask
Go to Top of Page

dcwebman
Starting Member

11 Posts

Posted - 2005-08-24 : 10:40:56
Typo, sorry. So I guess it comes down to having to create another field for continued masking. Thanks for the reply.
Go to Top of Page
   

- Advertisement -