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
 General SQL Server Forums
 New to SQL Server Programming
 Sum of Bitmasks

Author  Topic 

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2011-09-30 : 02:09:44
Hi All,
Can anyone provide me the good example for creating a bitmask value and how we use that. Also please provide me example on SUM of bitmasks as well. Its urgent for me guys.

Thanks,
Rams


rams

vmvadivel
Yak Posting Veteran

69 Posts

Posted - 2011-09-30 : 05:02:11
DECLARE @tblTestBit TABLE (iValue INT)

INSERT @tblTestBit
SELECT 4 UNION
SELECT 15

DECLARE @counter INT
SET @counter = 0

SELECT @counter = @counter | iValue
FROM @tblTestBit

--Result
SELECT @counter as [Result]

Best Regards
Vadivel

http://vadivel.blogspot.com
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2011-09-30 : 07:55:17
xor to the rescue!

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -