<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: T-SQL Bitwise Operations</title>
	<atom:link href="http://sqlfool.com/2009/02/bitwise-operations/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlfool.com/2009/02/bitwise-operations/</link>
	<description>Adventures in SQL Tuning - a blog for the rest of us</description>
	<lastBuildDate>Tue, 07 Feb 2012 21:28:07 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: recep hazer</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-7076</link>
		<dc:creator>recep hazer</dc:creator>
		<pubDate>Tue, 15 Nov 2011 08:17:44 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-7076</guid>
		<description>Here’s an interesting “bug” that I’ve found:

DECLARE @bitvar BIT
 SET @bitvar = 6
 PRINT @bitvar &amp; 1
 PRINT @bitvar &amp; 2
 PRINT @bitvar &amp; 4
 PRINT 6 &amp; 1
 PRINT 6 &amp; 2
 PRINT 6 &amp; 4

@bitvar is bit how the hell it supposed to get value 6 
try @bitvar as int there is no bug</description>
		<content:encoded><![CDATA[<p>Here’s an interesting “bug” that I’ve found:</p>
<p>DECLARE @bitvar BIT<br />
 SET @bitvar = 6<br />
 PRINT @bitvar &amp; 1<br />
 PRINT @bitvar &amp; 2<br />
 PRINT @bitvar &amp; 4<br />
 PRINT 6 &amp; 1<br />
 PRINT 6 &amp; 2<br />
 PRINT 6 &amp; 4</p>
<p>@bitvar is bit how the hell it supposed to get value 6<br />
try @bitvar as int there is no bug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quotes</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5799</link>
		<dc:creator>Quotes</dc:creator>
		<pubDate>Sat, 30 Apr 2011 03:31:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5799</guid>
		<description>Thanks for sharing this post.It is really worth reading.</description>
		<content:encoded><![CDATA[<p>Thanks for sharing this post.It is really worth reading.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nabarupam Deb</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5690</link>
		<dc:creator>Nabarupam Deb</dc:creator>
		<pubDate>Tue, 08 Mar 2011 12:57:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5690</guid>
		<description>What to do if the data is bigger than the BIGINT Range?</description>
		<content:encoded><![CDATA[<p>What to do if the data is bigger than the BIGINT Range?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paulo Pedro</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5219</link>
		<dc:creator>Paulo Pedro</dc:creator>
		<pubDate>Sun, 01 Aug 2010 16:25:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5219</guid>
		<description>DECLARE @bitvar BIT
SET @bitvar = 6
PRINT @bitvar &amp; 1
PRINT @bitvar &amp; 2
PRINT @bitvar &amp; 4
PRINT CAST(6 AS BIT) &amp; 1
PRINT CAST(6 AS BIT) &amp; 2
PRINT CAST(6 AS BIT) &amp; 4

This is one of many situations where we should cast values first.

:)</description>
		<content:encoded><![CDATA[<p>DECLARE @bitvar BIT<br />
SET @bitvar = 6<br />
PRINT @bitvar &amp; 1<br />
PRINT @bitvar &amp; 2<br />
PRINT @bitvar &amp; 4<br />
PRINT CAST(6 AS BIT) &amp; 1<br />
PRINT CAST(6 AS BIT) &amp; 2<br />
PRINT CAST(6 AS BIT) &amp; 4</p>
<p>This is one of many situations where we should cast values first.</p>
<p> <img src='http://sqlfool.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: compact treadmill</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5078</link>
		<dc:creator>compact treadmill</dc:creator>
		<pubDate>Thu, 04 Mar 2010 07:20:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5078</guid>
		<description>Helpful article and examples, Thanks.</description>
		<content:encoded><![CDATA[<p>Helpful article and examples, Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5069</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Tue, 16 Feb 2010 14:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5069</guid>
		<description>You can also do the same trick without creating a lookup table variable, like this:

[code]
declare @tmp table
	(
	val int,
	color nvarchar(100)
	)

insert into @tmp (val, color) VALUES (0, &#039;black&#039;)
insert into @tmp (val, color) VALUES (1, &#039;red&#039;)
insert into @tmp (val, color) VALUES (2, &#039;yellow&#039;)
insert into @tmp (val, color) VALUES (4, &#039;blue&#039;)
insert into @tmp (val, color) VALUES (8, &#039;white&#039;)



declare @newval int
set @newval = 6


select
	* 
from
	@tmp t cross join
	(SELECT (@newval) as val) n
where
	t.val &amp; n.val  0
[/code]</description>
		<content:encoded><![CDATA[<p>You can also do the same trick without creating a lookup table variable, like this:</p>
<p>[code]<br />
declare @tmp table<br />
	(<br />
	val int,<br />
	color nvarchar(100)<br />
	)</p>
<p>insert into @tmp (val, color) VALUES (0, 'black')<br />
insert into @tmp (val, color) VALUES (1, 'red')<br />
insert into @tmp (val, color) VALUES (2, 'yellow')<br />
insert into @tmp (val, color) VALUES (4, 'blue')<br />
insert into @tmp (val, color) VALUES (8, 'white')</p>
<p>declare @newval int<br />
set @newval = 6</p>
<p>select<br />
	*<br />
from<br />
	@tmp t cross join<br />
	(SELECT (@newval) as val) n<br />
where<br />
	t.val &amp; n.val  0<br />
[/code]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darren</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5066</link>
		<dc:creator>Darren</dc:creator>
		<pubDate>Fri, 12 Feb 2010 13:55:31 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5066</guid>
		<description>Here&#039;s an interesting &quot;bug&quot; that I&#039;ve found:

DECLARE @bitvar BIT
SET @bitvar = 6
            PRINT @bitvar &amp; 1
            PRINT @bitvar &amp; 2
            PRINT @bitvar &amp; 4
            PRINT 6 &amp; 1
            PRINT 6 &amp; 2
            PRINT 6 &amp; 4</description>
		<content:encoded><![CDATA[<p>Here&#8217;s an interesting &#8220;bug&#8221; that I&#8217;ve found:</p>
<p>DECLARE @bitvar BIT<br />
SET @bitvar = 6<br />
            PRINT @bitvar &amp; 1<br />
            PRINT @bitvar &amp; 2<br />
            PRINT @bitvar &amp; 4<br />
            PRINT 6 &amp; 1<br />
            PRINT 6 &amp; 2<br />
            PRINT 6 &amp; 4</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Get the Server level default connection properties for SQL Server using T-SQL &#124; Sankar Reddy, SQL Server Developer/DBA</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5064</link>
		<dc:creator>Get the Server level default connection properties for SQL Server using T-SQL &#124; Sankar Reddy, SQL Server Developer/DBA</dc:creator>
		<pubDate>Mon, 08 Feb 2010 16:27:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5064</guid>
		<description>[...] to use SP_CONFIGURE in SQL Server T-SQL Bitwise Operations  February 8th, 2010 &#124; Category: SQL Server, SQL Server 2005, SQL Server 2008, SQLServerPedia [...]</description>
		<content:encoded><![CDATA[<p>[...] to use SP_CONFIGURE in SQL Server T-SQL Bitwise Operations  February 8th, 2010 | Category: SQL Server, SQL Server 2005, SQL Server 2008, SQLServerPedia [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-5037</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 23 Dec 2009 18:55:42 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-5037</guid>
		<description>This area of programming is becoming a lost art.  Storing and retreiving data by using bit masks (as this article describes) is still a common use of bitwise operators, but there are so many other uses, namely data manipulation and calculation, that are becoming forgotton.</description>
		<content:encoded><![CDATA[<p>This area of programming is becoming a lost art.  Storing and retreiving data by using bit masks (as this article describes) is still a common use of bitwise operators, but there are so many other uses, namely data manipulation and calculation, that are becoming forgotton.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL Notes &#171; 36 Chambers &#8211; The Legendary Journeys: Execution to the max!</title>
		<link>http://sqlfool.com/2009/02/bitwise-operations/comment-page-1/#comment-4973</link>
		<dc:creator>SQL Notes &#171; 36 Chambers &#8211; The Legendary Journeys: Execution to the max!</dc:creator>
		<pubDate>Sun, 11 Oct 2009 02:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://sqlfool.com/?p=435#comment-4973</guid>
		<description>[...] after all.  Unfortunately, one of our legacy tables at work still uses these, so fortunately, Michelle Ufford has a good primer on how to do it.  Don&#8217;t do it, [...]</description>
		<content:encoded><![CDATA[<p>[...] after all.  Unfortunately, one of our legacy tables at work still uses these, so fortunately, Michelle Ufford has a good primer on how to do it.  Don&#8217;t do it, [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

