操作数数据类型数字对于“~”运算符无效

Operand data type numeric is invalid for '~' operator

~ 运算符不适用于 BIGINT 数据类型,

UPDATE Table
SET attrEx= attrEx & (~576460752303423488 )
where attrEx != 0

attrEx 类型:BIGINT

错误:

Operand data type numeric is invalid for '~' operator.

您需要将其转换为 bigint

UPDATE Table
SET attrEx= attrEx & (~CAST(576460752303423488 AS bigint) )
where attrEx != 0

这是documented here

Functions return bigint only if the parameter expression is a bigint data type. SQL Server does not automatically promote other integer data types (tinyint, smallint, and int) to bigint.
...snip...
Integer constants greater than 2,147,483,647 are converted to the decimal data type, not the bigint data type.