JavaScript Editor js editor     Web development 



Main Page

Sets a bit to 1 in a value of Numeric, Varbinary, or Blob type and returns the resulting value. There is a numeric and a binary version of the syntax.

Note:
If the specified expression is not an integer, it is converted to an integer before setting the bit.

BITSET(nNumericExpression1, nNumericExpression2)
BITSET(BinaryExpression [, nStartBit [, nBitCount]])

Parameters

nNumericExpression1


Specifies a Numeric value to set the bit.
nNumericExpression2


Specifies the position of the bit in nExpression1 to set to 1. nExpression2 can range from 0 to 31 with 0 as the bit farthest to the right.
BinaryExpression


Specifies a Varbinary or Blob expression.
[ nStartBit[, nBitCount]]


Specifies a starting zero-based number of the first bit to perform the operation as nStartBit and the number of bits to perform the operation as nBitCount. If you do not specify nStartBit and nBitCount, the operation applies to all bits in the expression. If you specify nStartBit only, the operation applies to nStartBit only.

Return Value

Numeric, Varbinary, or Blob. BITSET(В ) returns the specified expression with the specified bit set to 1.

Example

В Copy Code
x = 5  && 0101 binary
y = 1  && 2nd bit position (0 = 1st bit position)
? BITSET(x,y) && Returns 7, 0111 binary

See Also



JavaScript Editor js editor     Web development