<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Elegant Code &#187; SQL</title>
	<atom:link href="http://elegantcode.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Sun, 12 Feb 2012 04:40:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Three Times the Fun</title>
		<link>http://elegantcode.com/2008/12/31/three-times-the-fun/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=three-times-the-fun</link>
		<comments>http://elegantcode.com/2008/12/31/three-times-the-fun/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 02:37:10 +0000</pubDate>
		<dc:creator>Jason Grundy</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/12/31/three-times-the-fun/</guid>
		<description><![CDATA[Jason again. Over the past week, while most people have been enjoying some hard earned time off, I&#8217;ve been working&#8230;a lot. Joining me in my efforts have been fellow Elegant Coder Chris and Priyesh. The nature of the projects that we undertake here can make it difficult to apply some key development principles. A particularly [...]]]></description>
			<content:encoded><![CDATA[<p>Jason again. Over the past week, while most people have been enjoying some hard earned time off, I&#8217;ve been working&#8230;a lot. Joining me in my efforts have been fellow Elegant Coder <a href="http://elegantcode.com/about/chris-brandsma/">Chris</a> and Priyesh.</p>
<p>The nature of the projects that we undertake here can make it difficult to apply some key development principles. A particularly large obstacle has proven to be multiple developer projects&#8230;or lack thereof. Please don&#8217;t lecture me on the evils of this approach as I know the price that we pay for our sins. In fact when I first came on board here some 16 months ago this was the first thing that I changed (where I could) and it has had a more significant impact on the quality of our software than anything else that we have done.</p>
<p>And this fact was underlined by what we have achieved during the past week. In terms of quality and quantity I have not seen such a high level of output for a significant period of time. We challenged and supported each other and we had a bunch of fun too. Thanks guys &#8211; you rock!</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/12/31/three-times-the-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2008 RC0 is out</title>
		<link>http://elegantcode.com/2008/06/07/sql-server-2008-rc0-is-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sql-server-2008-rc0-is-out</link>
		<comments>http://elegantcode.com/2008/06/07/sql-server-2008-rc0-is-out/#comments</comments>
		<pubDate>Sat, 07 Jun 2008 20:03:08 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/06/07/sql-server-2008-rc0-is-out/</guid>
		<description><![CDATA[http://blogs.technet.com/andrew/archive/2008/06/06/sql-server-2008-rc0.aspx Good to see this started.&#160; I like that it is RC0 (RC-Zero) and not RC1.]]></description>
			<content:encoded><![CDATA[<p><img src="http://i.microsoft.com/global/sqlserver/2008/en/us/PublishingImages/logo-header-sql08-dg.gif"> </p>
<p><a title="http://blogs.technet.com/andrew/archive/2008/06/06/sql-server-2008-rc0.aspx" href="http://blogs.technet.com/andrew/archive/2008/06/06/sql-server-2008-rc0.aspx">http://blogs.technet.com/andrew/archive/2008/06/06/sql-server-2008-rc0.aspx</a></p>
<p>Good to see this started.&nbsp; I like that it is RC0 (RC-Zero) and not RC1. </p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/06/07/sql-server-2008-rc0-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data Dude Extensibility &#8211; How IBM integrated DB2 into Visual Studio</title>
		<link>http://elegantcode.com/2008/06/06/data-dude-extensibility-how-ibm-integrated-db2-into-visual-studio/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=data-dude-extensibility-how-ibm-integrated-db2-into-visual-studio</link>
		<comments>http://elegantcode.com/2008/06/06/data-dude-extensibility-how-ibm-integrated-db2-into-visual-studio/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 13:52:59 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Tools & Utilities]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/06/06/data-dude-extensibility-how-ibm-integrated-db2-into-visual-studio/</guid>
		<description><![CDATA[I am sitting in a room at Tech Ed 208 with about 15 people who got up early enough for this session. I am blown away there aren&#8217;t more people in here, but I guess the after-party at Universal Studios last night kept people in bed late this morning. This session is a joint presentation [...]]]></description>
			<content:encoded><![CDATA[<p>I am sitting in a room at Tech Ed 208 with about 15 people who got up early enough for this session. I am blown away there aren&#8217;t more people in here, but I guess the after-party at Universal Studios last night kept people in bed late this morning. This session is a joint presentation by <a href="http://blogs.msdn.com/gertd/" target="_blank">Gert Drapers</a> (the actual Data Dude) and Brent Gross the from IBM for the DB2 integration project team.</p>
<p>It is clear (and stated) that other RDBMS vendors will follow suit as MS has provided a fundamentally pluggable model for vendors to integrate their DBs into Visual Studio with a provider model. Can you smell Oracle, boys and girls? I can. Gert is being vague about who they are working with. MySQL will be cool.</p>
<p>There are several levels of extensibility:</p>
<ul>
<li>DB Provider</li>
<ul>
<li>This is the actual connectivity to your own RDBMS. This provider is responsible for talking to the VS model layer for the DB project and translating between your DB and the model. </li>
</ul>
<li>VS Features</li>
<ul>
<li>The ability to alter features in Visual Studio, like: </li>
<ul>
<li>Refactorings available for a given provider.</li>
<li>Syntax highlighting</li>
<li>language formatting rules for reverse engineering operations</li>
</ul>
<li>Static analysis rules for your particular SQL language</li>
<ul>
<li>Yes, you get static analysis rules for TSQL. This is the death clock for select * from &#8230;</li>
<li>Static analysis in BD2 SQL may be different than that in MS TSQL</li>
<li>You can write your own static analysis rules in .Net by inheriting from the provided Rule class or *yeah* implementing an interface (are we hearing a theme out of MS?) I suppose if your company were anal enough, you could actually implement your proprietary naming convention rules as static analysis rules. Gert actually did this is an demo by writing a rule that checked column names to ensure they were in Pascal case. Neato. The funny part is when some of the developers in the room started telling him how his demo code could be refactored. Lol.</li>
</ul>
</ul>
<li>Model Extensibility</li>
<ul>
<li>VS actually works against a model of the data store and lets the provider do the translation.</li>
<li>Using the model paradigm for DB development provides full round trip model to implementation support for any given DB.</li>
<li>Gert actually showed a little command line app that looked at a Northwind DB in Access and a different Northwind DB in SQL Server and compared them. There would be very different SQL syntaxes if we were simply comparing creation scripts. The DBs showed as the same. More accurately, the models checked as the same. Cool.</li>
<li>So, I could script the process of taking a DB2 database and migrating it to SQL Server, or visa versa, in this model paradigm.</li>
</ul>
</ul>
<p>This session signaled several things to me.</p>
<ol>
<li>MS products really are being designed with extensibility and integration in mind. No really, this time.</li>
<li>The Data Dude model of working with databases has genuine merit. The days of SSMS (SQL Server Management Studio) and the Query Analyzer fan base are numbered. Treating DBAs as developers really is a better model.</li>
<li>Something different is occurring at MS with the changing of the guard.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/06/06/data-dude-extensibility-how-ibm-integrated-db2-into-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Parameter Sniffing and what to do about it</title>
		<link>http://elegantcode.com/2008/05/17/sql-parameter-sniffing-and-what-to-do-about-it/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sql-parameter-sniffing-and-what-to-do-about-it</link>
		<comments>http://elegantcode.com/2008/05/17/sql-parameter-sniffing-and-what-to-do-about-it/#comments</comments>
		<pubDate>Sat, 17 May 2008 16:53:50 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/05/17/sql-parameter-sniffing-and-what-to-do-about-it/</guid>
		<description><![CDATA[Here was an interesting problem we ran into yesterday.&#160; We have about 50 people using a web site that I help build.&#160; All but one of them was logging in with no problems.&#160; But any time our &#8220;special&#8221; user logged in (lets call him John Doe) he would get a timeout. That one left us [...]]]></description>
			<content:encoded><![CDATA[<p>Here was an interesting problem we ran into yesterday.&nbsp; We have about 50 people using a web site that I help build.&nbsp; All but one of them was logging in with no problems.&nbsp; But any time our &#8220;special&#8221; user logged in (lets call him John Doe) he would get a timeout.</p>
<p>That one left us scratching our heads.&nbsp; Luckily we have top notch security in place, so we were able to log in as him as well (without him knowing, and without knowing his password).</p>
<p><font color="#808080"><em>Hint: use forms authentication and write your own membership provider on a mirrored production site that no one outside of IT knows about.</em></font></p>
<p>When we log in as him we also get a timeout.&nbsp; OK, time to fire up SQL Server Query Profiler and see what is going on&#8230;which doesn&#8217;t take long.&nbsp; We see the query, a stored procedure really, taking +30 seconds to run.&nbsp; When we log in as a different user it takes less than one second.&nbsp; In fact we can log in as any other user and it takes less than one second.</p>
<p>Next step, dissect the query.&nbsp; We pull the query out of the stored proc (it isn&#8217;t that complicated of a query) and run it from Management Studio with John Doe&#8217;s info.&nbsp; ~1 second.</p>
<p>WHAT??!!!</p>
<p>My coworker did some web searching and stumbled on the answer (Google to the rescue, giving us answers even when we really don&#8217;t know the question): <a href="http://blogs.msdn.com/queryoptteam/archive/2006/03/31/565991.aspx">SQL Parameter Sniffing</a>.</p>
<p>WHAT??!!!</p>
<p>The rundown is that when SQL Server compiles the query and creates the execution plan, if you pass parameters from the stored procedure call directly into the query, SQL Server will use the values passed in to &#8220;influence&#8221; the query plan.&nbsp; That can be a bad thing.&nbsp; Here is the Microsoft definition:</p>
<p><em>&#8220;Parameter sniffing&#8221; refers to a process whereby SQL Server&#8217;s execution environment &#8220;sniffs&#8221; the current parameter values during compilation or recompilation, and passes it along to the query optimizer so that they can be used to generate potentially faster query execution plans. The word &#8220;current&#8221; refers to the parameter values present in the statement call that caused a compilation or a recompilation.</em></p>
<p>Luckily the fix is easy.&nbsp; Take your stored procedure that looks like this (generalizing a query here:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> MyProcedure</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     @UserName nvarchar(20)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> <span style="color: #0000ff">AS</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #0000ff">BEGIN</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #008000">-- Insert statements for procedure here</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">SELECT</span> DisplayName, FirstName, LastName </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     <span style="color: #0000ff">FROM</span> dbo.<span style="color: #0000ff">User</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     <span style="color: #0000ff">WHERE</span> UserName = @UserName</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> <span style="color: #0000ff">END</span></pre>
</div>
</div>
<p>And change it to this:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> MyProcedure</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     @UserName nvarchar(20)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> <span style="color: #0000ff">AS</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #0000ff">BEGIN</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #0000ff">DECLARE</span> @myUserName nvarchar(20)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">SET</span> @myUserName = @UserName</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     <span style="color: #008000">-- Insert statements for procedure here</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     <span style="color: #0000ff">SELECT</span> DisplayName, FirstName, LastName </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     <span style="color: #0000ff">FROM</span> dbo.<span style="color: #0000ff">User</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     <span style="color: #0000ff">WHERE</span> UserName = @myUserName</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> END</pre>
</div>
</div>
<p>Look on lines 5,6, and 10 for changes.</p>
<p>What did I really do?&nbsp; I once again proved that any programming problem can be solved with another layer of indirection.&nbsp; Really.&nbsp; </p>
<p>For some strange reason, when you pass the parameters (@UserName in this case) to a local variable (@myUserName) SQL Server will no longer use the value of the parameter (@UserName) to influence the query plan.</p>
<p>If you don&#8217;t believe me (and really, you shouldn&#8217;t ever believe the word of just one person), do a Google search on <a href="http://www.google.com/search?q=sql+parameter+sniffing&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a">SQL Parameter Sniffing</a>.&nbsp; </p>
<p>We tried it, tested it, did a performance check on it, it worked.&nbsp; But this now goes onto the top of my &#8220;Strange fixes for SQL Server&#8221; stack.</p>
<p>Other references:</p>
<ul>
<li><a title="http://omnibuzz-sql.blogspot.com/2006/11/parameter-sniffing-stored-procedures.html" href="http://omnibuzz-sql.blogspot.com/2006/11/parameter-sniffing-stored-procedures.html">Parameter Sniffing &amp; Stored Procedures Execution Plan, SQL Garbage Collector</a>
<li><a href="http://glennberrysqlperformance.spaces.live.com/blog/cns!45041418ECCAA960!541.entry?wa=wsignin1.0">How to Disable Parameter Sniffing in SQL Server 2005, Glenn Berry</a>
<li><a href="http://blogs.msdn.com/queryoptteam/archive/2006/03/31/565991.aspx">Tips, Tricks, and Advice from the SQL Server Query Optimization Team</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/05/17/sql-parameter-sniffing-and-what-to-do-about-it/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SQL Ejaculation</title>
		<link>http://elegantcode.com/2008/03/21/sql-ejaculation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sql-ejaculation</link>
		<comments>http://elegantcode.com/2008/03/21/sql-ejaculation/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 04:01:32 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/03/21/sql-ejaculation/</guid>
		<description><![CDATA[SQL Injection is the practice of slipping SQL code into a database execution command to get the DB to do something indirectly. Although this is a famous condition of a security vulnerability, it is less touted but more widely used by nefarious developers looking to subvert soul-crushing DBAs. A typical example is the 1 month [...]]]></description>
			<content:encoded><![CDATA[<p><a href="statement := " target="_blank" name="" + userName + "" ;??=";??" WHERE="WHERE" users="users" FROM="FROM" *="*" select="select">SQL Injection</a> is the practice of slipping SQL code into a database execution command to get the DB to do something indirectly. Although this is a famous condition of a security vulnerability, it is less touted but more widely used by nefarious developers looking to subvert soul-crushing DBAs.</p>
<p>A typical example is the 1 month turnaround cycle for a new stored proc resulting in the inclusion by a developer of a &quot;secret&quot; stored proc that will execute whatever SQL sent to it as a string. I bring this up only because I know it is a less talked about, but very real.</p>
<p>The exact opposite of SQL Injection is (named by me) <strong>SQL Ejaculation</strong>. SQL Ejaculation is the practice of DBAs trying to insert their idea of view logic into an application via stored procedures.</p>
<p>Here is a classic example of SQL Ejaculation.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> sp_getCustomers
<span style="color: #0000ff">AS</span>
<span style="color: #0000ff">SELECT</span> &quot;&lt;tr&gt;&lt;td&gt;&quot; + FirstName + &quot;&lt;/td&gt;&lt;td&gt;&quot; + LastName + &quot;&lt;/td&gt;&lt;/tr&gt;&quot;
<span style="color: #0000ff">FROM</span> Customer</pre>
</div>
<p>And before you even ask, yes, people really do this. In fact, when I learned how to do it 15 years ago or so, I thought it was kind of cool. We all grow wiser, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/03/21/sql-ejaculation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2008 Release &quot;Revision&quot;</title>
		<link>http://elegantcode.com/2008/02/22/sql-server-2008-release-revision/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sql-server-2008-release-revision</link>
		<comments>http://elegantcode.com/2008/02/22/sql-server-2008-release-revision/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 23:38:58 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/02/22/sql-server-2008-release-revision/</guid>
		<description><![CDATA[SQL Server 2008 won&#8217;t release with the other 2008 products in March as originally planned, according to this article. It would be easy to take a cheap shot at this, but I would instead like to applaud the company&#8217;s decision to wait until the dish is fully baked. How many of us work in a [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Server 2008 won&#8217;t release with the other 2008 products in March as originally planned, <a href="http://blogs.technet.com/dataplatforminsider/archive/2008/01/25/microsoft-sql-server-2008-roadmap-clarification.aspx" target="_blank">according to this article</a>. It would be easy to take a cheap shot at this, but I would instead like to applaud the company&#8217;s decision to wait until the dish is fully baked.</p>
<p>How many of us work in a time-boxed release schedule with no apparent logical reason given for shipping on a particular date? The fact that Microsoft is choosing to take the hit in revenue and reputation to deliver something better, but later, should give us all heart. In an industry where quality is often forsaken for time-to-market, I will take quality any day.</p>
<p>One of my favorite quotes on the subject (who said it, I don&#8217;t know) is, &quot;Customers will forget that you delivered late. They will always remember that you delivered crap.&quot;</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/02/22/sql-server-2008-release-revision/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

