<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/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>Search results matching tags 'Software Design', 'SQL Server', and 'Security'</title><link>http://bloggingabout.net/search/SearchResults.aspx?a=1&amp;o=DateDescending&amp;tag=Software+Design,SQL+Server,Security&amp;orTags=0</link><description>Search results matching tags 'Software Design', 'SQL Server', and 'Security'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>The Myth of Stored Procedures Preference</title><link>http://bloggingabout.net/blogs/adelkhalil/archive/2008/01/05/the-myth-of-stored-procedures-preference.aspx</link><pubDate>Sat, 05 Jan 2008 22:16:28 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:453656</guid><dc:creator>Adel Khalil</dc:creator><description>&lt;p&gt;When looking to the Stored Proscedures debate, there is always those three factors you should measure by.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Productivity&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;- Span code base over multiple staging environments is a pain and harder to maintain.&lt;/p&gt; &lt;p&gt;- Versioning sp code is way harder than versioning application code.&lt;/p&gt; &lt;p&gt;- Minor change to the design require changing in both the SPs and the DAL code.&lt;/p&gt; &lt;p&gt;- Todays IDEs are more advanced than most of the RDBMS offers, implementing on IDEs is obviously preferable.&lt;/p&gt; &lt;p&gt;- Switching between two seprate world to implement single method is always pain.&lt;/p&gt; &lt;p&gt;- It&amp;#39;s impossible to cover every single scenario and write SP for it, which will lead to write these SP as you go, huge consistency problem.&lt;/p&gt; &lt;p&gt;- There is no way to only update single param in the Update method using SPs as there isn&amp;#39;t optional parameters, on every update you need to supply full param collection.&lt;/p&gt; &lt;p&gt;- SPs are not portable if you want to develop application that run over multiple DBMS you will be writing SPs for each DBMS, standard SQL is portable.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;- Big myth over here, using SPs not guarante best security practice and certinly dosn&amp;#39;t mean that your application is SQL Injection proof you can write code like this&lt;/p&gt; &lt;p&gt;string s = &amp;quot;EXEC sp_GetCustomerByEmail &amp;#39;&amp;quot; + txtEmailAddress.Text + &amp;quot;&amp;#39;&amp;quot;;&lt;/p&gt; &lt;p&gt;and you will be using SP and still open to all kind of SQL Injection.&lt;/p&gt; &lt;p&gt;- Another myth regarding security is that if you are using Ad-hoc queries you *most likely* grand permissions for CRUD operations for your application user on the database, no you are not, that&amp;#39;s why Views are invented.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;often when SPs vs. Ad-hoc queries debate intoduced the performance card played, SPs advocates says SPs are pre-compiled which is not let met quate like &lt;a href="http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx" target="_blank"&gt;Frans&lt;/a&gt; did from SQL Server Books Online&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;&lt;font color="#626262"&gt;SQL Server 2000 and SQL Server version 7.0 incorporate a number of changes to statement processing that extend many of the performance benefits of stored procedures to all SQL statements. SQL Server 2000 and SQL Server 7.0 do not save a partially compiled plan for stored procedures when they are created. A stored procedure is compiled at execution time, like any other Transact-SQL statement. SQL Server 2000 and SQL Server 7.0 retain execution plans for all SQL statements in the procedure cache, not just stored procedure execution plans.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;So with no pre-compilation and caching for both SPs and SQL statments there is no advantage for SPs here, in some other databases the SPs compiled into C or C++ but this isn&amp;#39;t the case in SQL Server 7.0/2000.&lt;/p&gt; &lt;p&gt;I have introuduced my view on the SP vs. Dynamic SQL i don&amp;#39;t see any benfit of SPs over the huge amount of productivity, performance that you will gain with dynamic SQL, the only benfit in peformance you will get it when using Managed SPs (SQL Server 2005) but for 0.7/2000 SPs isn&amp;#39;t the right choice for most of the scenarios.&lt;/p&gt; &lt;p&gt;Read more (diverse views):&lt;/p&gt; &lt;p&gt;- Frans Bouma&amp;#39;s &lt;a href="http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx"&gt;Stored procedures are bad, m&amp;#39;kay?&lt;/a&gt;&lt;/p&gt; &lt;p&gt;- Jeff Atwood&amp;#39;s &lt;a href="http://www.codinghorror.com/blog/archives/000292.html" target="_blank"&gt;Stored Procs vs. Ad-hoc&lt;/a&gt; , &lt;a href="http://www.codinghorror.com/blog/archives/000275.html" target="_blank"&gt;Give me parametrized SQL, or give me death&lt;/a&gt;&lt;/p&gt; &lt;p&gt;- Eric Wise&amp;#39;s &lt;a target="_blank"&gt;The Pragmatic Adhoc SQL vs Stored Procedures Discussion&lt;/a&gt;&lt;/p&gt; &lt;p&gt;- Rob Howard&amp;#39;s &lt;a href="http://weblogs.asp.net/rhoward/archive/2003/11/17/38095.aspx" target="_blank"&gt;Don&amp;#39;t use stored procedures yet? Must be suffering from NIHS (Not Invented Here Syndrome)&lt;/a&gt;&lt;/p&gt; &lt;p&gt;- Jeremy D. Miller&amp;#39;s &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/05/25/145450.aspx" target="_blank"&gt;Why I do not use Stored Procedures&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>