<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devpinoy.org/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>leonidas blog - All Comments</title><link>http://devpinoy.org/blogs/leonidas/default.aspx</link><description>Grip. Stand. Throw.</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>re: Hashtable, ListDictionary and HybridDictionary</title><link>http://devpinoy.org/blogs/leonidas/archive/2007/08/13/hashtable-listdictionary-and-hybriddictionary.aspx#12992</link><pubDate>Sat, 18 Aug 2007 21:32:58 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:12992</guid><dc:creator>keithrull</dc:creator><description>&lt;p&gt;Yup! and HybridDictionary is threadsafe too ;)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=12992" width="1" height="1"&gt;</description></item><item><title>re: How to avoid Dynamic SQL in Stored Procedure</title><link>http://devpinoy.org/blogs/leonidas/archive/2007/08/15/how-to-avoid-dynamic-sql-in-stored-procedure.aspx#12899</link><pubDate>Thu, 16 Aug 2007 05:59:10 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:12899</guid><dc:creator>leonidas</dc:creator><description>&lt;p&gt;I used LIKE comparison just for my example only. It can be = or &amp;lt;&amp;gt; rather. And the parameter type can be other type and not varchar.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=12899" width="1" height="1"&gt;</description></item><item><title>re: How to avoid Dynamic SQL in Stored Procedure</title><link>http://devpinoy.org/blogs/leonidas/archive/2007/08/15/how-to-avoid-dynamic-sql-in-stored-procedure.aspx#12897</link><pubDate>Thu, 16 Aug 2007 05:22:51 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:12897</guid><dc:creator>bonskijr</dc:creator><description>&lt;p&gt;like what jop suggested checkout sommarskog's article. leverage default parameters to stored proc(&lt;a rel="nofollow" target="_new" href="http://devpinoy.org/blogs/bonskijr/archive/2006/02/16/1708.aspx"&gt;devpinoy.org/.../1708.aspx&lt;/a&gt;) so that instead of having this:&lt;/p&gt;
&lt;p&gt;[code]&lt;/p&gt;
&lt;p&gt;WHERE ((@supplierLength &amp;gt; 0 AND S.CompanyName LIKE @supplierName + '%') OR @supplierLength = 0) AND&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;((@categoryLength &amp;gt; 0 AND C.CategoryName LIKE @categoryName + '%') OR @categoryLength = 0)&lt;/p&gt;
&lt;p&gt;[/code]&lt;/p&gt;
&lt;p&gt;you can have instead:&lt;/p&gt;
&lt;p&gt;WHERE (S.CompanyName LIKE @supplierName + '%' OR @supplierName IS NULL )&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;AND (C.CategoryName LIKE @categoryName + '%' OR @categoryName IS NULL)&lt;/p&gt;
&lt;p&gt;with the advantage of just calling your stored proc:&lt;/p&gt;
&lt;p&gt;EXEC mySample @supplierName = 'ACME'&lt;/p&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;p&gt;EXEC mySample @categoryName = 'TIME BOMB'&lt;/p&gt;
&lt;p&gt;Having said that however, the irony of this is that the best way to do a dynamic search(imo) is to use dynamic t-sql not by using stored proc but parameterized dynamic sql passed by your client to sql. While the solution, even with sommarskog's is great and all it will be unwieldy once you have additional search parameters and will be PITA to maintain.&lt;/p&gt;
&lt;p&gt;What I did using NH or any solution was to have a SearchCriteria class with all the search params as properties and every setter appends to the internal sql string which builds those parameters as either hQl or sql and execute it. &lt;/p&gt;
&lt;p&gt;hth&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=12897" width="1" height="1"&gt;</description></item><item><title>re: How to avoid Dynamic SQL in Stored Procedure</title><link>http://devpinoy.org/blogs/leonidas/archive/2007/08/15/how-to-avoid-dynamic-sql-in-stored-procedure.aspx#12891</link><pubDate>Thu, 16 Aug 2007 03:24:28 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:12891</guid><dc:creator>leonidas</dc:creator><description>&lt;p&gt;Thanks jop. I will check that later.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=12891" width="1" height="1"&gt;</description></item><item><title>re: How to avoid Dynamic SQL in Stored Procedure</title><link>http://devpinoy.org/blogs/leonidas/archive/2007/08/15/how-to-avoid-dynamic-sql-in-stored-procedure.aspx#12890</link><pubDate>Thu, 16 Aug 2007 03:16:35 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:12890</guid><dc:creator>jop</dc:creator><description>&lt;p&gt;For dynamic searches, I find this article very useful: [&lt;a rel="nofollow" target="_new" href="http://www.sommarskog.se/dyn-search.html"&gt;www.sommarskog.se/dyn-search.html&lt;/a&gt;]. The same author (an SQL Server MVP) also has an article about dynamic SQL. Visit that too. [jop]&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=12890" width="1" height="1"&gt;</description></item><item><title>re: Looking at Maintainability</title><link>http://devpinoy.org/blogs/leonidas/archive/2007/08/09/looking-at-maintainability.aspx#12686</link><pubDate>Fri, 10 Aug 2007 06:18:47 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:12686</guid><dc:creator>jop</dc:creator><description>&lt;p&gt;Yep...&lt;/p&gt;
&lt;p&gt;Make it work&lt;/p&gt;
&lt;p&gt;Make it right.&lt;/p&gt;
&lt;p&gt;And if necessary, Make it fast.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=12686" width="1" height="1"&gt;</description></item><item><title>re: Looking at Maintainability</title><link>http://devpinoy.org/blogs/leonidas/archive/2007/08/09/looking-at-maintainability.aspx#12684</link><pubDate>Fri, 10 Aug 2007 06:05:52 GMT</pubDate><guid isPermaLink="false">99090821-4da1-4a75-98c2-a35884625ff7:12684</guid><dc:creator>lamia</dc:creator><description>&lt;p&gt;The first thing I discovered was to put codes into modules(in VB6). Then I learned how to create Types, those c-structs look-alike, that's what they're called right? Yes, optimization should come last(IMHO). For most experienced programmers though, they could make optimized code w/out sacrificing maintainability.&lt;/p&gt;
&lt;p&gt;I read somewhere on the internet that you should optimize algorithm and not code. Though when you really think of it, you still have to optimize code. :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devpinoy.org/aggbug.aspx?PostID=12684" width="1" height="1"&gt;</description></item></channel></rss>