<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8960363264253615574</id><updated>2011-04-21T16:32:07.296-07:00</updated><title type='text'>Codedelicious</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codedelicious.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8960363264253615574/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://codedelicious.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Lukasz Maslanka</name><uri>http://www.blogger.com/profile/04592438934966022134</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8960363264253615574.post-1670907168913787107</id><published>2008-02-27T07:48:00.000-08:00</published><updated>2008-03-05T11:22:35.951-08:00</updated><title type='text'>TRUE or FALSE</title><content type='html'>&lt;span style="font-family:arial;"&gt;I know that sometimes you run into a problem of passing a parameter into a stored procedure that indicates TRUE or FALSE. But you need to return both fields true and false on say true and only false on false. There are a number of ways to solve this problem but one solution stands out as the winner for me.&lt;br /&gt;&lt;br /&gt;So assuming our table Documents has a fields called Name (varchar) and Private (bit), we want to return all records from the table when we pass in TRUE and only the Non Private records (FALSE) when we pass in false.&lt;br /&gt;&lt;br /&gt;Input Parameter for the stored procedure is called @Private BIT,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;font-size:85%;color:#009900;"&gt;&lt;blockquote&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;font-size:85%;color:#009900;"&gt;SELECT Name&lt;br /&gt;FROM Documents As [d]&lt;br /&gt;WHERE [d].[Private] &amp;lt; CASE WHEN @Private = 1 THEN 2 ELSE 1 END&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color:#c0c0c0;"&gt;&lt;span style="font-family:arial;"&gt;So now our select will return both TRUE and FALSE when then @Private parameter is true and only false when it is false.&lt;br /&gt;I think this is a helpful tidbit of info to help you out on your next stored procedure.&lt;br /&gt;I credit Jon Marshall for this code.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;color:#009900;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8960363264253615574-1670907168913787107?l=codedelicious.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedelicious.blogspot.com/feeds/1670907168913787107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8960363264253615574&amp;postID=1670907168913787107' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8960363264253615574/posts/default/1670907168913787107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8960363264253615574/posts/default/1670907168913787107'/><link rel='alternate' type='text/html' href='http://codedelicious.blogspot.com/2008/02/simple-select.html' title='TRUE or FALSE'/><author><name>Lukasz Maslanka</name><uri>http://www.blogger.com/profile/04592438934966022134</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
