This is embarassing. I've been coding in T-SQL for years, and when I've had to invert a bit, I've been writing stuff like this:
case @bit when 0 then cast ( 1 as bit ) when 1 then cast ( 0 as bit ) else null end
because the NOT operator doesn't work on bits. Today, I thought to myself: "Bitwise NOT. Didn't I see that in Books Online?" And yep, there it is. Instead of typing the above to invert a bit, all you need is the bitwise NOT operator "~".
~@bit
Forehead, meet palm.
Remember Me
a@href@title, i, strike, u
Copyright © 2003-2008 Falafel Software Inc.
Subscribe to Falafel Blogs
The opinions expressed herein are Falafel's employees own personal opinions and do not represent Falafel Software's view in any way in case they go bananas!