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.
Author |
Topic |
Karander
Starting Member
34 Posts |
Posted - 2006-12-27 : 08:29:27
|
Hi, How to set exactly n-th bit in binary field?For Instance:0x0000 0000 0000 0010And i want to set '1' on 2. bitin result i would like to have:0x0000 0000 0000 0010and ...0x0000 0000 0000 0010to0x0000 0000 0000 0000Thx fo help |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-27 : 08:41:24
|
AND it with reverse bitmap:(0x0000 0000 0000 0010 AND 0x0000 0000 0000 0010) AND (0x1111 1111 1111 1101)In SQL Server,Select (2 & 2) & 1 Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
Karander
Starting Member
34 Posts |
Posted - 2006-12-27 : 08:58:24
|
but if i had to create function setting appropiate bit in value and returning binary field, how would you do it? :)A udf function passing binary value, bit to set and position... |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-27 : 09:33:29
|
There is an undocumented SP - sp_MSsetbit. See if it helps.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|