Reputation: 1185
This is a first time I'm executing bitwise query and I get a problem that I do not understand. I have a Table1 with binary(128) ColumnA I execute
select *
from Table1
where Table1.ColumnA ^ CAST(127 as binary(128)) <> 0
It should produce all records that have any of first 7 bits set to 1. Instead I get this error
The data types binary and binary are incompatible in the '^' operator.
So is the right way to write this query?
Upvotes: 0
Views: 68
Reputation: 91666
Both operands cannot be binary
. One, must be int
, tinyint
or smallint
. See the docs for more info.
I would try just using ^ 127
instead:
select *
from Table1
where Table1.ColumnA ^ 127 <> 0
Upvotes: 1