<?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: How to simulate optional parameters in SQL</title>
	<atom:link href="http://www.xaprb.com/blog/2005/12/11/optional-parameters-in-the-where-clause/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2005/12/11/optional-parameters-in-the-where-clause/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Frederick Lin : Optional Parameters in SQL</title>
		<link>http://www.xaprb.com/blog/2005/12/11/optional-parameters-in-the-where-clause/#comment-13562</link>
		<dc:creator>Frederick Lin : Optional Parameters in SQL</dc:creator>
		<pubDate>Tue, 23 Oct 2007 01:01:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=62#comment-13562</guid>
		<description>[...] certainly be using this more often.&#160; I found an article the other day explaining how to simulate optional parameters in SQL without duplicating a single SELECT statement several times, each with a different WHERE [...]</description>
		<content:encoded><![CDATA[<p>[...] certainly be using this more often.&nbsp; I found an article the other day explaining how to simulate optional parameters in SQL without duplicating a single SELECT statement several times, each with a different WHERE [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2005/12/11/optional-parameters-in-the-where-clause/#comment-3569</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Mon, 29 Jan 2007 16:57:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=62#comment-3569</guid>
		<description>&lt;p&gt;There can be.  If you enter SMIT% then the database server can do a prefix match, which can use indexes.  If you enter %MIT% it becomes a full-length substring search, which is not indexable.  So yes, there is always a potential for a bad query to result.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>There can be.  If you enter SMIT% then the database server can do a prefix match, which can use indexes.  If you enter %MIT% it becomes a full-length substring search, which is not indexable.  So yes, there is always a potential for a bad query to result.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Locusta</title>
		<link>http://www.xaprb.com/blog/2005/12/11/optional-parameters-in-the-where-clause/#comment-3568</link>
		<dc:creator>Locusta</dc:creator>
		<pubDate>Mon, 29 Jan 2007 16:51:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=62#comment-3568</guid>
		<description>&lt;p&gt;Hello,

Is there a performance penalty between these 2 statements:&lt;/p&gt;

&lt;pre&gt;select * from table1
where (@param1 is null or col1 = @param1)
    and (@param2 is null or col2 = @param2)&lt;/pre&gt;

&lt;pre&gt;select * from table1
where (@param1 is null or col1 &lt;strong&gt;like&lt;/strong&gt; @param1)
    and (@param2 is null or col2 &lt;strong&gt;like&lt;/strong&gt; @param2)&lt;/pre&gt;

&lt;p&gt;This would allow the user to key in e.g. SMIT% to search for a customer name starting with SMIT, but if he keys in SMITH, then only the exact name would appear in the result list.

Is this good practice, or should I avoid?

Thanks for this great article!&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Is there a performance penalty between these 2 statements:</p>
<pre>select * from table1
where (@param1 is null or col1 = @param1)
    and (@param2 is null or col2 = @param2)</pre>
<pre>select * from table1
where (@param1 is null or col1 <strong>like</strong> @param1)
    and (@param2 is null or col2 <strong>like</strong> @param2)</pre>
<p>This would allow the user to key in e.g. SMIT% to search for a customer name starting with SMIT, but if he keys in SMITH, then only the exact name would appear in the result list.</p>
<p>Is this good practice, or should I avoid?</p>
<p>Thanks for this great article!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2005/12/11/optional-parameters-in-the-where-clause/#comment-1500</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Tue, 15 Aug 2006 11:13:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=62#comment-1500</guid>
		<description>&lt;p&gt;DOH!  You are right!  I&#039;ll amend the article.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>DOH!  You are right!  I&#8217;ll amend the article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: core</title>
		<link>http://www.xaprb.com/blog/2005/12/11/optional-parameters-in-the-where-clause/#comment-1499</link>
		<dc:creator>core</dc:creator>
		<pubDate>Tue, 15 Aug 2006 10:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=62#comment-1499</guid>
		<description>&lt;p&gt;Heya,&lt;/p&gt;

&lt;p&gt;Shouldn&#039;t this:&lt;/p&gt;

&lt;pre&gt;select * from table1
where (col1 is null or col1 = @param1)
    and (col2 is null or col2 = @param2)&lt;/pre&gt;

&lt;p&gt;read:&lt;/p&gt;

&lt;pre&gt;select * from table1
where (@param1 is null or col1 = @param1)
    and (@param2 is null or col2 = @param2)&lt;/pre&gt;

&lt;p&gt;? Cheers, Will&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Heya,</p>
<p>Shouldn&#8217;t this:</p>
<pre>select * from table1
where (col1 is null or col1 = @param1)
    and (col2 is null or col2 = @param2)</pre>
<p>read:</p>
<pre>select * from table1
where (@param1 is null or col1 = @param1)
    and (@param2 is null or col2 = @param2)</pre>
<p>? Cheers, Will</p>
]]></content:encoded>
	</item>
</channel>
</rss>

