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 2008 Forums
 Transact-SQL (2008)
 boolean operation on integer

Author  Topic 

olibara
Yak Posting Veteran

94 Posts

Posted - 2012-01-25 : 06:36:45
Hello

Is it possible to do some logical operation on integer within SQL Syntax

As I can write in VB or C

VB
A=(A OR B)
A=(A AND B)

C#
A |= B;
A &= B;

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-01-25 : 06:39:43
[code]BEGIN TRAN

DECLARE @a INT = 1234
DECLARE @b INT = 1436

SELECT @a & @b -- Bitwise AND
SELECT @a | @b -- Bitwise OR
SELECT ~@a -- Birwize NOT
SELECT @a ^ @b -- Bitwise Exlusive OR

DECLARE @c INT

SELECT @c = (@a ^ @b) -- Assignment
SELECT @c

ROLLBACK
[/code]
Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

olibara
Yak Posting Veteran

94 Posts

Posted - 2012-01-25 : 07:07:39
Easy !
Thanks a lot Charlie
Go to Top of Page
   

- Advertisement -