<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Jeremiah Peschka, SQL Server Developer</title>
	
	<link>http://facility9.com</link>
	<description>Jeremiah Peschka's ruminations on sql, ruby, c# and other things</description>
	<lastBuildDate>Tue, 02 Feb 2010 16:25:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/facility9" /><feedburner:info uri="facility9" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license><item>
		<title>When is a Lookup not a Lookup?</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/vD4ATQH9NRA/when-is-a-lookup-not-a-lookup</link>
		<comments>http://facility9.com/2010/02/02/when-is-a-lookup-not-a-lookup#comments</comments>
		<pubDate>Tue, 02 Feb 2010 06:00:10 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[syndication]]></category>
		<category><![CDATA[Application Development]]></category>
		<category><![CDATA[performance tuning]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1314</guid>
		<description><![CDATA[Execution plans are great things. They give us an insight into how SQL Server is putting together queries and why they run slowly.
One immediate thing I look for in an execution plan is a Key Lookup. In a Key Lookup operation, SQL Server has to reference the clustered index on the table because a value [...]]]></description>
			<content:encoded><![CDATA[<p>Execution plans are great things. They give us an insight into how SQL Server is putting together queries and why they run slowly.</p>
<p>One immediate thing I look for in an execution plan is a Key Lookup. In a Key Lookup operation, SQL Server has to reference the clustered index on the table because a value it&#8217;s looking for is not present in the index that was used to find the row.</p>
<p>Normally, when you look at the Key Lookup, you will see a list of output columns. This is a great way to help you modify your indexes and make sure that you can avoid these extra disk hits by sacrificing a tiny bit of storage space.<br />
<div id="attachment_1315" class="wp-caption alignnone" style="width: 381px"><a href="http://facility9.com/files/2010/02/normal_output_list.png"><img src="http://facility9.com/files/2010/02/normal_output_list.png" alt="" title="normal_output_list" width="371" height="299" class="size-full wp-image-1315" /></a><p class="wp-caption-text">A Normal Output List from a Query Plan</p></div></p>
<p>Today, while troubleshooting a query that is never finishing, I ran across this gem.<br />
<div id="attachment_1316" class="wp-caption alignnone" style="width: 374px"><a href="http://facility9.com/files/2010/02/empty_output_list.png"><img src="http://facility9.com/files/2010/02/empty_output_list.png" alt="" title="empty_output_list" width="364" height="328" class="size-full wp-image-1316" /></a><p class="wp-caption-text">Empty. Bereft of Meaning. Nothing.</p></div></p>
<p>There&#8217;s no output list in the Key Lookup. I, wrongly, thought that Key Lookups would always include an output list. What&#8217;s going on here?</p>
<p>Well, here&#8217;s the scoop. I have the following, sample, table:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> dbo.<span style="color: #202020;">ServiceList</span> <span style="color: #808080;">&#40;</span>
  ServiceListId <span style="color: #0000FF;">BIGINT</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span> <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span>,
  BillId <span style="color: #0000FF;">BIGINT</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span>,
  ServiceMonth <span style="color: #0000FF;">DATETIME</span>
<span style="color: #808080;">&#41;</span>;</pre></div></div>

<p>In this query, ServiceList is referenced through a CROSS APPLY&#8217;d inline function. The inline function references the BillId and ServiceListId. There&#8217;s an index on ServiceList that contains both of these columns:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">INDEX</span> IX_ServiceList_BillId <span style="color: #0000FF;">ON</span> dbo.<span style="color: #202020;">ServiceList</span>
<span style="color: #808080;">&#40;</span>
  BillId
<span style="color: #808080;">&#41;</span>
<span style="color: #808080;">IN</span>CLUDE <span style="color: #808080;">&#40;</span>ServiceListId, ServiceMonth<span style="color: #808080;">&#41;</span>;</pre></div></div>

<p>This index is correctly being used by the query optimizer but in the past it&#8217;s only been used to perform lookups and push data to screen (or somewhere). So, what we&#8217;re seeing here makes sense. The CROSS APPLY needs to reference the BillId so the compiler checks the situation out and decides to use IX_ServiceList_BillId in order get the BillId. Since the index only includes ServiceListId, it has to perform a Key Lookup. </p>
<blockquote><p><strong>Protip:</strong> included data is only included in the index; it is not indexed.</p></blockquote>
<p>To avoid this kind of behavior, I need to change this index to actually index on the combination of BillId and ServiceListId like so:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">INDEX</span> IX_ServiceList_BillId <span style="color: #0000FF;">ON</span> dbo.<span style="color: #202020;">ServiceList</span>
<span style="color: #808080;">&#40;</span>
  BillId,
  ServiceListId
<span style="color: #808080;">&#41;</span>
<span style="color: #808080;">IN</span>CLUDE <span style="color: #808080;">&#40;</span>ServiceMonth<span style="color: #808080;">&#41;</span>;</pre></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=vD4ATQH9NRA:w5TCYBc-mX0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=vD4ATQH9NRA:w5TCYBc-mX0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=vD4ATQH9NRA:w5TCYBc-mX0:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=vD4ATQH9NRA:w5TCYBc-mX0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=vD4ATQH9NRA:w5TCYBc-mX0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=vD4ATQH9NRA:w5TCYBc-mX0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=vD4ATQH9NRA:w5TCYBc-mX0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/vD4ATQH9NRA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2010/02/02/when-is-a-lookup-not-a-lookup/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://facility9.com/2010/02/02/when-is-a-lookup-not-a-lookup</feedburner:origLink></item>
		<item>
		<title>How the Hell Did I Get Here?</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/Zg6kDcl30XE/how-the-hell-did-i-get-here-2</link>
		<comments>http://facility9.com/2010/01/19/how-the-hell-did-i-get-here-2#comments</comments>
		<pubDate>Tue, 19 Jan 2010 17:32:47 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[nonsense]]></category>
		<category><![CDATA[syndication]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[goats]]></category>
		<category><![CDATA[hackery]]></category>
		<category><![CDATA[omgponies]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[sqljackass]]></category>
		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1296</guid>
		<description><![CDATA[Paul Randal started this chain post. He tagged Steve Jones who, in turn, tagged Jack Corbett who finally tagged me. I&#8217;m pretty sure everyone who nominally makes sense has already been tagged at this point thus leaving Jack to scrape the bottom of the barrel.
Like Jack, I think I could approach this in a number [...]]]></description>
			<content:encoded><![CDATA[<p>Paul Randal started this <a href='http://www.sqlskills.com/BLOGS/PAUL/post.aspx?id=785a0c9c-e035-43ea-bbac-685d10d5802d' target='_blank'>chain post</a>. He tagged <a href='http://www.sqlservercentral.com/blogs/steve_jones/archive/2010/01/18/what-three-things-brought-me-here.aspx' target='_blank'>Steve Jones</a> who, in turn, tagged <a href='http://wiseman-wiseguy.blogspot.com/2010/01/three-events-that-brought-me-here.html?utm_source=feedburner&amp;utm_medium=twitter&amp;utm_campaign=Feed:+WiseManOrWiseGuyYouDecide+(Wise+man+or+Wise+guy%3F++You+decide)' target='_blank'>Jack Corbett</a> who finally tagged me. I&#8217;m pretty sure everyone who nominally makes sense has already been tagged at this point thus leaving Jack to scrape the bottom of the barrel.</p>
<p>Like Jack, I think I could approach this in a number of different ways. I think I&#8217;ve already answered the professional route that I took. If I haven&#8217;t, it&#8217;s probably because my professional route isn&#8217;t all that interesting and it&#8217;s also all available on <a href='http://www.linkedin.com/in/jeremiahpeschka' target='_blank'>LinkedIn</a>. You can, and should, fill in the job changes on my resume with something interesting like &#8220;After being attacked by a bear in the janitor&#8217;s closet at CareWorks Technologies, Jeremiah decided to take a safer job at HMB (they have no bears on staff as janitors).&#8221;</p>
<p>Anyway, you asked for it, you got it: how the hell did I get here?</p>
<h3>I&#8217;m a Rock and Roll Machine</h3>
<p>I love being on stage and in front of people, even though it terrifies the crap out of me. Apparently, I like that adrenaline surge. I&#8217;ve been playing guitar since I was 13 years old.  When I was 23 I answered an advertisement and auditioned for a band. I got the job after 5 minutes. </p>
<p>Being a musician takes a lot of hard work, dedication, and practice. You work for hours and hours as a group, and hours and hours on your own preparing for a show. At that show, you&#8217;re going to walk up on stage and try to steal the attention of a room full of people who would, frankly, rather be doing one of a million other things &#8211; playing pool, talking to friends, hitting on that girl across the bar &#8211; than listening to you. As musicians, it was our job to get their attention, hold it for an hour, and make sure that they were happy about it. That job gets even harder when you&#8217;re in a band that only plays original material.</p>
<p>What seemed really fun &#8211; being in a band &#8211; turned out to be a lot of work &#8211; practicing three nights a week for four hours a night with the band and then practicing even more on my own. I learned a lot about myself &#8211; my tolerance for bullshit, how to get attention, and how to act in front of a crowd of people &#8211; while I was in the band. I also learned a lot about how to budget scarce resources &#8211; money and time &#8211; while still getting the job done &#8211; getting to the show.</p>
<p>The band eventually fell apart, as most do, but I learned many valuable lessons that I carry with me &#8211; time and resource management, performing skills, and how to make an ass of yourself and be okay with it. Most importantly, I learned that passion alone isn&#8217;t enough. You have to work for something if you really want to be good at it.</p>
<h3>Everything to Everyone</h3>
<p>The fact is, I&#8217;m not everything to everyone. But for a long time, I thought that I could do it.</p>
<p>Before and while I was in the band, I was married. The band took up a lot of time and it took a lot of time away from my marriage. While being in a band didn&#8217;t cause my eventual divorce, I&#8217;m sure it contributed to it (I quit the band about a year before my ex-wife and I quit the marriage). I remarried pretty quickly and that marriage ended almost as fast as it started.</p>
<p>Throughout all of this, though, there&#8217;s a huge undercurrent &#8211; I was trying to make everyone happy. I was trying to be a good husband, musician, developer, friend, son, brother, step-father, and about a million other things. I stretched myself thin and I broke. </p>
<p>These days, I know that I can only be me and that I&#8217;m the only person I need to make happy. There&#8217;s a reason why I work with SQL Server but I program with Ruby, why I listen to old school hardcore punk but I play a bizarre blend of folk and country, why I devote more time to my friends and family than I have before &#8211; these things all make me happy. If it doesn&#8217;t make me happy and I don&#8217;t need to do it to live, I don&#8217;t do it.</p>
<h3>Self-Fulfilling Catastrophe</h3>
<p>A couple of paragraphs ago I said &#8220;I stretched myself thin and I broke.&#8221; I really do mean that. During the first divorce, I moved into a tiny house on the ass end of Columbus, stopped paying most of my bills, and ended up living on as little as $20 a week. The funny part, though, is that I always found the cash to go out and party, or to stay in and party. This became a bad habit even once the divorce was done and I should have been back on my feet. Over the next 4 years everything spiralled completely out of control.</p>
<p>I&#8217;m pretty sure there were more than a few times I nearly lost my job. I frequently called in &#8220;sick&#8221; from the crowded patio of a bar at 1:30AM, had my car repossessed, racked up so much debt that people were calling my family members to find out where I was, and I partied seven nights a week. I lost a lot of my friends and damaged most of my remaining friendships irrepairably in the process. Throughout this ordeal, a few of my friends stood by me. They didn&#8217;t give up on me despite my ardent attempts to turn myself into a drooling train wreck of a human being.</p>
<p>In June of 2008, I gave it all up. I realized that I was a total train wreck and that everything around me was completely out of control. My career was stagnant. I was sliding backwards as a person. I wasn&#8217;t meeting any of my goals for myself because I was too busy slowly killing myself.</p>
<p>I stopped drinking. I got the help I needed and I began the long, painful, process of pulling myself up by my shoelaces. I dried out. </p>
<p>By August, I had completed the SQL Server 2005 MCITP: Database Developer certification. I started the Columbus chapter of PASS in October. I started paying back all of my bad debt (only a few months left to go). Nine months after I quit drinking, I quit my one to two pack a day smoking habit (sorry about that one, Mom and Dad) &#8211; I <em>never</em> would have thought I could end my 13 year addiction to nicotine.</p>
<p>I have a great relationship with my family and friends now, it&#8217;s better than anything I could ever hope for.</p>
<p>I learned a lot of things from this.</p>
<ol>
<li>I can be horribly selfish.</li>
<li>There&#8217;s nothing better than not being that selfish.</li>
<li>I can do damn near anything I want to do if I put my mind to it.</li>
<li>There are some things in life that are so important you can&#8217;t afford to overlook them.</li>
</ol>
<h3>Afterward</h3>
<p>This summer, one of my friends (someone who met me at my lowest and stuck by me through everything) is giving me the greatest honor I could ever hope for: on June 19th I&#8217;ll be officiating his wedding. Like a lot of people, I wouldn&#8217;t change a thing about my life.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=Zg6kDcl30XE:all17hOtLCI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=Zg6kDcl30XE:all17hOtLCI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=Zg6kDcl30XE:all17hOtLCI:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=Zg6kDcl30XE:all17hOtLCI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=Zg6kDcl30XE:all17hOtLCI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=Zg6kDcl30XE:all17hOtLCI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=Zg6kDcl30XE:all17hOtLCI:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/Zg6kDcl30XE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2010/01/19/how-the-hell-did-i-get-here-2/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://facility9.com/2010/01/19/how-the-hell-did-i-get-here-2</feedburner:origLink></item>
		<item>
		<title>Knowing and not Knowing</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/mLrc4zECnZo/knowing-and-not-knowing</link>
		<comments>http://facility9.com/2010/01/14/knowing-and-not-knowing#comments</comments>
		<pubDate>Thu, 14 Jan 2010 14:00:22 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[Professional Development]]></category>
		<category><![CDATA[nonsense]]></category>
		<category><![CDATA[goats]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1279</guid>
		<description><![CDATA[In the IT field, people have the expectation that we&#8217;ll always have an answer or a solution. The problem is that we usually don&#8217;t have the answer. A lot of the time, we don&#8217;t even have the beginnings of a clue. Your reaction when you don&#8217;t have an answer speaks volumes. I&#8217;m going to use [...]]]></description>
			<content:encoded><![CDATA[<p>In the IT field, people have the expectation that we&#8217;ll always have an answer or a solution. The problem is that we usually don&#8217;t have the answer. A lot of the time, we don&#8217;t even have the beginnings of a clue. Your reaction when you don&#8217;t have an answer speaks volumes. I&#8217;m going to use a story to illustrate this point.</p>
<h3 id="the_story">The Story</h3>
<p>Adam and Bill work together at Amalgamated Spats. During a design meeting Adam mentions a product that could solve some of the problems the developers at Amalgamated Spats are facing. Although Adam is a specialist, he has a great deal of work on his plate and Bill is designated to develop the features. Bill isn&#8217;t a specialist, he&#8217;s a generalist. Bill is a great developer, but he&#8217;s unfamiliar with this specific product.</p>
<p>Over the course of development, Bill makes great strides. Unfortunately, there are some features that he isn&#8217;t able to solve programmatically even though they are included in the product. These features are features that were sold as part of reason to use the product. When Adam and Bill&#8217;s manager talks to Bill about his progress, Bill tells the manager that he wasn&#8217;t able to get the features done because it isn&#8217;t possible using the product. The problem is that the features do exist in the product, they just weren&#8217;t available the way Bill was using it. </p>
<p>Adam and Bill&#8217;s manager is upset that they&#8217;ve put so much faith in this product. While the manager trusts Adam, Bill has been working with the product day in and day out, trying to implement these features &#8211; why wouldn&#8217;t Bill tell the truth? As a result, Adam loses credibility. He can get that credibility back, and certainly will, but for a while it&#8217;s gone.</p>
<h3 id="the_problem">The Problem</h3>
<p>There are a couple of problems with this situation:</p>
<ol>
<li>Bill has effectively thrown Adam under the bus (we call this bussing). Adam has lost credibility with the manager because he gave &#8220;wrong&#8221; advice.</li>
<li>Bill said &#8220;No&#8221; when he should have said &#8220;I don&#8217;t know.&#8221;</li>
</ol>
<p>Of these, the second is far worse. Ultimately, the first problem will go away and Adam will gain that respect back and everyone will be happy again. But the second problem speaks volumes.</p>
<h3 id="it8217s_not_okay_to_say_8220i_don8217t_know8221">It&#8217;s Not Okay to Say &#8220;I don&#8217;t know&#8221;</h3>
<p>But I just said that Bill should have said &#8220;I don&#8217;t know,&#8221; right? Wrong. Saying &#8220;I don&#8217;t know&#8221; and ending it at that is not acceptable. In this crazy software development world, it&#8217;s our job to find the solutions to problems. Did you read that correctly? I didn&#8217;t say that it&#8217;s our job to code the solutions to problems, it&#8217;s our job to find the solutions to problems. Sometimes the solution is to use an existing solution or feature which you can only find through research. Do you see what I&#8217;m getting at yet? &#8220;I don&#8217;t know&#8221; isn&#8217;t acceptable but saying &#8220;I don&#8217;t know, but I&#8217;ll find out&#8221; is perfectly acceptable.</p>
<h3 id="what8217s_the_difference">What&#8217;s the difference?</h3>
<p>When you say &#8220;I don&#8217;t know&#8221; and you stop there you&#8217;re effectively throwing your hands in the air and giving up. You&#8217;re not only admitting that you don&#8217;t know, but that your lack of knowing is the end of it. It ends the conversation</p>
<p>If you say &#8220;I don&#8217;t know, but let&#8217;s find out,&#8221; you&#8217;re telling the other person that you don&#8217;t know the answer and it bothers you. It bothers you so much that you&#8217;re going to find out the answer. You&#8217;re advertising your inquisitive mindset and the way you solve problems.</p>
<h3 id="but_what_should_i_do">What Should I Do?</h3>
<p>The next time someone asks you a question where you don&#8217;t know the answer, tell them you don&#8217;t know. Be completely upfront about it. Follow that up with &#8220;but I&#8217;ll find out.&#8221; Then, actually find out the answer. Research the problem, research the product, and consult with experts &#8211; even if you think you are one.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=mLrc4zECnZo:RT-7voF2w_I:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=mLrc4zECnZo:RT-7voF2w_I:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=mLrc4zECnZo:RT-7voF2w_I:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=mLrc4zECnZo:RT-7voF2w_I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=mLrc4zECnZo:RT-7voF2w_I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=mLrc4zECnZo:RT-7voF2w_I:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=mLrc4zECnZo:RT-7voF2w_I:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/mLrc4zECnZo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2010/01/14/knowing-and-not-knowing/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://facility9.com/2010/01/14/knowing-and-not-knowing</feedburner:origLink></item>
		<item>
		<title>Project 52</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/bxnlUAGDLEQ/project-52</link>
		<comments>http://facility9.com/2010/01/11/project-52#comments</comments>
		<pubDate>Mon, 11 Jan 2010 13:00:22 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[nonsense]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1274</guid>
		<description><![CDATA[Rather than make a resolution to blog more frequently, I&#8217;ve decided to hold myself accountable and I joined Project 52. Here&#8217;s what Project 52 is all about:
Project52 is a personal challenge geared toward getting fresh content on your website. The goal is to write at least 1 new article per week for 1 year. Because [...]]]></description>
			<content:encoded><![CDATA[<p>Rather than make a resolution to blog more frequently, I&#8217;ve decided to hold myself accountable and I joined <a href='http://project52.info' target='_blank'>Project 52</a>. Here&#8217;s what Project 52 is all about:</p>
<blockquote><p>Project52 is a personal challenge geared toward getting fresh content on your website. The goal is to write at least 1 new article per week for 1 year. Because we all know what it‘s like to procrastinate on our content. A website is not just a fresh design that can be uploaded to the web and forgotten about!</p></blockquote>
<p>I&#8217;m hoping I can hold up my end of the bargain, but here&#8217;s to hoping.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=bxnlUAGDLEQ:3qfQPwrRBK0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=bxnlUAGDLEQ:3qfQPwrRBK0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=bxnlUAGDLEQ:3qfQPwrRBK0:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=bxnlUAGDLEQ:3qfQPwrRBK0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=bxnlUAGDLEQ:3qfQPwrRBK0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=bxnlUAGDLEQ:3qfQPwrRBK0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=bxnlUAGDLEQ:3qfQPwrRBK0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/bxnlUAGDLEQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2010/01/11/project-52/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://facility9.com/2010/01/11/project-52</feedburner:origLink></item>
		<item>
		<title>O/R-Ms: Panacea or Polio Braces?</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/-OO2ta-PqZI/or-ms-panacea-or-polio-braces</link>
		<comments>http://facility9.com/2010/01/05/or-ms-panacea-or-polio-braces#comments</comments>
		<pubDate>Tue, 05 Jan 2010 14:00:52 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[syndication]]></category>
		<category><![CDATA[Application Development]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[performance tuning]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1266</guid>
		<description><![CDATA[In case you haven&#8217;t heard, there is a huge difference between the way that software developers and database professionals operate &#8211; there are accepted use paradigms and development methodologies for both worlds. Unfortunately for everyone, they don&#8217;t match up. Object-oriented programming languages operate on single entities: objects. Databases work with sets. Objects sometimes have relationships [...]]]></description>
			<content:encoded><![CDATA[<p>In case you haven&#8217;t heard, there is a huge difference between the way that software developers and database professionals operate &#8211; there are accepted use paradigms and development methodologies for both worlds. Unfortunately for everyone, they don&#8217;t match up. Object-oriented programming languages operate on single entities: objects. Databases work with sets. Objects sometimes have relationships that are difficult to effectively map in a relational database. Database entities frequently do not even correspond to application entities. How are these two wildly different paradigms supposed to interact?</p>
<p>Object-Relational Mappers, O/R-Ms, are often hailed as the solution to the differences between object-oriented code and the relational storage layer. By simply using some magical tool, library, or bong we can code, map, or smoke our way to software that accounts for the differences between databases and object-oriented software. The thing is: this doesn&#8217;t work.</p>
<h3 id="magical_snake_oil">Magical Snake Oil</h3>
<p>A lot of developers see the database as nothing more than a hole for objects. You tie a string around them in the application layer, put some pretty ribbons on the string so you can find your object later, and you then chuck it in the hole. When you need it later, you find the pretty ribbon and pull the object back out, right?</p>
<p>Not quite, it appears. First you have to create some kind of mapping so you know which tables are associated with which objects. With some O/R-Ms you have to create mappings in XML. These mappings require maintenance whenever your application-layer or database changes. They are also error prone when you are setting them up. Don&#8217;t believe me? Search the web for developers bitching about working with Hibernate and NHibernate mappings. Solving non-trivial mapping problems isn&#8217;t easy with these tools. </p>
<p>Isn&#8217;t one of the reasons for using O/R-Ms to cut down on the amount of difficult, &#8220;specialized&#8221; code that you have to write? Instead of writing SQL &#8211; a language purpose built to the task of querying relational data from a database &#8211; we resort to creating magical XML mappings, write more code using fluent style code with lambda expressions and other advanced language features, or rely on magical automapping to wire up classes directly with tables. Think about it: in order to avoid writing special purpose code, we&#8217;re writing special purpose code in languages that aren&#8217;t even well suited to the task at hand. If these tools are solving problems, why do so many developers bitch about them and write code that generates their entire O/R-M layer, which is really just code to generate mappings to and from SQL.</p>
<h3 id="shackled_to_the_solution">Shackled to the Solution</h3>
<p>If everything is as horrible as I say, why are people using O/R-Ms? A lot of O/R-M software works. Technically, an AMC Gremlin also works. It has wheels, doors, and an engine. It is suitable for driving you around town. It is not ideal. Likewise, O/R-Ms are suitable to the task of getting at data, but they are not ideal. I hear the arguments all the time, and I&#8217;m going to discuss some of the more prominent ones. I feel it&#8217;s important to put my biases out there, so keep the following in mind:</p>
<ol>
<li>I am a database developer and a production DBA.</li>
<li>I still work with OO languages, just not as part of my day job.</li>
<li>I don&#8217;t hate O/R-Ms; they have a place. They just aren&#8217;t a magical cure-all.</li>
</ol>
<h4 id="but_my_database_is_just_an_object_store">But my database is just an object store</h4>
<p>Use a flat file. You don&#8217;t need anything more complicated than that. Clearly, since you think of your database as an object store you&#8217;re not overly concerned about data integrity, reportability, concurrency, consistency, or any of the other reasons to use a relational database. Hell, use an <a target='_blank' href="http://db4o.com">object-oriented database</a> for all I care. Just stop using RDBMSes and complaining that they don&#8217;t meet your needs. Or take a refresher course in everything that an RDBMS provides. I&#8217;ll wait.</p>
<p>Putting my vitriol aside, a database is more than an object store. By lowering the database to the level of nothing more than an object store, you&#8217;re admitting that you haven&#8217;t taken the time to fully understand your business problem or the underlying data. Business problems are, fundamentally, problems related to ever changing data and ways to store and retrieve that data programmatically for human consumption. Objects and classes are ideal for working with and describing systems with different behaviors in a set of related ideas. The OO paradigm works with relatively constant data. I have a Phone base class (I&#8217;m not making the obvious IPhone interface joke) with a <code>call(string number)</code> method. The PayPhone class will implement a different call method than the CellPhone class. This works wonderfully for modeling the behavior of a telephone. In the database, we&#8217;re likely to have a table with columns PhoneId, PhoneType, and Number. There&#8217;s no actual differentiation between how we&#8217;re storing any of these phones. Having an OO paradigm actually complicates the issue.</p>
<h4 id="but_i_don8217t_have_time_to_write_crud_stored_procedures">But I don&#8217;t have time to write CRUD stored procedures</h4>
<p>You know what? Neither do I. I generate them. SQL Server Management Studio will generate them for me. <a target='_blank' href="http://ssmstoolspack.com">SSMS Tools Pack</a> adds a context menu option that reads &#8220;Generate CRUD.&#8221; I could, in a very short amount of time, write T-SQL to generate dynamic CRUD for me that will even only update the values supplied. </p>
<p>People, I hate to break it to you, but if you took the time to understand SQL you could probably write your complex mappings using views and stored procedures faster than you could write your O/R-M XML/fluent/automapping magic code. It&#8217;s just as easy to use stored procedures and views as it is to use tables. Trust me, I know this.</p>
<p>You&#8217;re just being lazy or scared of SQL.</p>
<h4 id="but_my_o_r_m_uses_prepared_statements_and_those_are_just_like_stored_procedures">But my O/R-M uses prepared statements and those are just like stored procedures</h4>
<p>I understand that you believe that prepared statements are just like stored procedures because some <a target='_blank' href="http://en.wikipedia.org">expert</a> told you so. I&#8217;m very happy that you have good friends who have use their free time to selectively quote documentation and educate you about things they don&#8217;t understand.</p>
<p>Thing is: prepared statements are not just like stored procedures.</p>
<p>I will admit that with a prepared statement you are buying yourself the ability to have cached queries. But what if your line of business app is one of a hundred apps on a server that is near capacity. Odds are that your prepared statement execution plans aren&#8217;t going to stay in memory. My DBA voodoo talk means that your prepared statement (the one that&#8217;s &#8220;just as good as a stored procedure&#8221;) is actually worthless. With stored procedures us DBA voodoo priests can do all kinds of things that you didn&#8217;t even know about &#8211; we can tell the database which indexes to use. We can force the database to use execution plans that we saved off ages ago. Hell, we can even re-write your table structure into something that suits the relational model a lot better and hide it that re-write through the stored procedures.</p>
<h4 id="but_i_digress">But I digress</h4>
<p>No, seriously, I was digressing. The point is, developers start making bitchy noises whenever it&#8217;s suggested that they do something in SQL. These are the same developers who suggest some new tool/library because it&#8217;s faster/better/stronger/<a target='_blank' href="http://www.youtube.com/watch?v=K2cYWfq--Nw">more Daft Punk</a> than ever.</p>
<p>There are a lot of problems that O/R-Ms seek to solve. In an ideal world, it would work. In reality, it doesn&#8217;t. The instant you start relying on an automated solution to fix everything, you&#8217;re losing. I strongly advocate automation. Hell, I&#8217;ve automated a ton of my job away already so that I have time to do the things I enjoy: helping our development staff understand what they&#8217;re working with and finding the best way to solve the problem. Sometimes that solution has nothing to do with the database. That&#8217;s fine by me. But we put that solution where it belongs. We aren&#8217;t shoving everything into an OO box because that&#8217;s what we know. </p>
<h3 id="the_cure_is_making_us_sick">The Cure Is Making Us Sick</h3>
<p>O/R-Ms make assumptions about data access. Many O/R-Ms assume that you allow access directly to the underlying tables. A lot of them also assume that your tables reside in the default database schema. The thing is, there are a lot of assumptions going on. If you work with the O/R-M library, you&#8217;re missing a lot of the built-in features that come with your database out of the box.</p>
<h4 id="security">Security</h4>
<p>Let&#8217;s look at an example of a corporate intranet. We have a rule that the HR department data is not visible to the sales department and vice versa. If we&#8217;re working purely with an O/R-M, we&#8217;re going to have to identify the classes and tables that map to each department and write programming logic to make sure that HR users can&#8217;t see sales data and that the sales people can&#8217;t see HR data. But, if we go ahead and connect directly to the database with Access or Excel, anyone can go ahead and see these tables.</p>
<p>Working with database features like schemas and security, we can lock down the tables, views, stored procedures, and functions on a schema-by-schema basis. It&#8217;s possible to give the sales department access to specific HR information while denying them carte blanche to all HR data.</p>
<h4 id="data_access">Data Access</h4>
<p>Something else to take into account is universal data access. If we&#8217;re writing all of our data access logic in an O/R-M, we&#8217;re going to need to create a robust service layer that everyone can communicate with. Depending on the size of the company, we&#8217;ll have to create multiple service layers to make it possible to access our data. Why? All of our logic, all of our rules, all knowledge about the data is embedded in the O/R-M. </p>
<p>Let&#8217;s say that we are working in a large corporation. We have some legacy Java applications, some front line apps that were written in PHP, and new development is going on in .NET. Our team has started development and they&#8217;re using WCF and an O/R-M to get to the data in the database. We&#8217;ve got logic embedded in our data access layer. At the inception of the project we were under the assumption that no other applications would need to interface with our data. Unfortunately, we&#8217;ve done such a good job that the other development teams would like to get to our data as well. Java and PHP can&#8217;t talk to our WCF service layer. So, we have to write some SOAP services to talk to the Java and PHP code. Any time that we change or add new functionality to our WCF layer we have to add to or change those SOAP services as well. If we had originally gone with data access logic embedded in the database through stored procedures and views, it would have been simple to give the other teams access to our database objects but not the underlying tables. In short, we would have a low-level data access layer in the database that sits just above our data and below our code. </p>
<p>The database provides a universal way to get at the data in the database, agnostic of any platform or programming language.</p>
<h4 id="data_life_code_life">Data Life, Code Life</h4>
<p>Do you remember what programming language you were using five or ten years ago? There&#8217;s a pretty good chance that it&#8217;s not the same language that you&#8217;re using today. Next, think about how old your data is. There&#8217;s an even better chance that you&#8217;re working with data that is a lot older than five or ten years. Sure, the underlying platform may have changed from one RDBMS vendor to another but the structure of the data has stayed the same and our data access logic, if written in SQL, has probably changed very little from RDMBS to RDBMS. </p>
<p>As time goes on, the data structure will change at a very slow pace. I can&#8217;t predict what language we&#8217;ll be using in the application layer in five or ten years. However, I can assure you that developers don&#8217;t want to maintain a legacy data access layer because too much logic is embedded in the layer to move away from it. Instead, what will happen is that there is going to be an expensive and lengthy conversion project to move from the existing programming language to the new programming language. These conversion projects are frequently hidden in project time frames, but they exist and they add time to your projects &#8211; time that could be used to provide features to the users or work on far more interesting projects.</p>
<h4 id="there_is_no_magic_cure">There is no Magic Cure</h4>
<p>Data lives longer than code. If you don&#8217;t believe me, ask around. The data I&#8217;m working with goes back seven years; we&#8217;ve been using .NET for 15 months. At the recent <a target='_blank' href="http://summit.sqlpass.org">PASS Summit</a> I spoke with people who have data that is 30 years old and I&#8217;ve heard stories of people working with data older than that. If this ancient data is an RDBMS, there&#8217;s a great chance that the application accessing it are written in a variety of languages, some old and some new. They aren&#8217;t constant. Developers have come and gone. The data is permanent. There is a universal language for accessing it.</p>
<p>Databases provide features and functionality that we frequently re-implement in application code. It&#8217;s incredibly important to consider where we&#8217;re placing logic lest we incur technical debt that will take orders of magnitude longer to fix than to develop correctly. Take the time and figure out when you want to pay for that feature. Is moving your release date up by several weeks more important than saving six months of time down the road?</p>
<h3 id="always_learning">Always Learning</h3>
<p>As knowledge workers, we should always be acquiring more knowledge. Knowledge comes through deepening our current understanding of a subject as welling as adding breadth to our experience and expertise. That&#8217;s right, we&#8217;re supposed to keep learning new programming languages and increasing our knowledge of the ones we already know. Heck, <em>The Pragmatic Programmer</em> suggests learning a new programming language every year to stay on top of your game. </p>
<p>While you are busy learning the hot new languages, or revisiting existing languages, you&#8217;re missing something: SQL is a language. By refusing to learn SQL apart from simple SELECT statements, you are refusing to leverage the most powerful piece of software at your disposal. I understand that set-based programming is different from the type of programming that you&#8217;re used to, but it is a perfect fit for the problem domain: working with data. </p>
<h3 id="a_working_example">A Working Example</h3>
<p>MySpace is arguably the biggest pile of insanity to ever be unleashed upon the internet, barring twitter. And yet, somehow it keeps running. Why? Because they know when to leverage the power of the database. They&#8217;ve learned that there is some functionality that can be handled in the data tier and they use a native solution to solve the problem.</p>
<p>When <a target='_blank' href="http://www.microsoft.com/casestudies/Case_Study_Detail.aspx?CaseStudyID=4000004532">MySpace were facing scalability problems</a> as the site grew larger, they made use of SQL Server&#8217;s Service broker to handle communication between multiple scale-out servers. Using SQL Server Service Broker helped them ensure that transactions were atomic across multiple servers. They built a custom tool &#8211; Service Dispatcher &#8211; that build on the technology already provided by SQL Server Service Broker</p>
<p>They took the time to understand their tools.</p>
<h3 id="it8217s_not_all_bad">It&#8217;s Not All Bad</h3>
<p>Lest you think that I despise O/R-Ms and I&#8217;m some kind of horrible data zealot, let me assure you of a few things:</p>
<ol>
<li>I am a data zealot.</li>
<li>I like some O/R-Ms</li>
</ol>
<p>A good O/R-M makes it very apparent what it does and where its limitations are. Just like a good language. T-SQL is a good language. I know where the limitations are. Anyone who uses it for a while knows what the limitations are. That&#8217;s okay; we know what it&#8217;s good at.</p>
<p>Likewise, when I&#8217;m writing Ruby on Rails code, I know where the limitations of ActiveRecord are. It makes them very apparent to me and it gives me ways to drop down into native SQL and it behaves just as well. When I did .NET development for a living, we used LLBLGen Pro. It, like ActiveRecord, does some very intelligent things. I always knew the limits of LLBLGen.</p>
<p>A poor O/R-M solution tries to be everything to everyone. It supplies pseudo-languages to query the database that are, really, bizarre subsets of SQL with slightly non-SQL like syntax that make it just confusing enough.</p>
<h3 id="but_what_about8230">But What About&#8230;</h3>
<h4 id="linq">LINQ</h4>
<p>LINQ is a really cool idea. I haven&#8217;t worked with it enough to make a judgment call on it. Aesthetically speaking, I think it uglies up code with a giant chunk o&#8217; nasty that looks like it doesn&#8217;t belong. But, that being said, it also offers a way to query data into an internal memory representation of what appears to be a set and then join that to existing collections of objects. Pretty cool, eh?</p>
<h4 id="active_record">Active Record</h4>
<p>If we&#8217;re talking about the Ruby O/R-M framework, I think it&#8217;s pretty good. The limitations are clearly plotted out and yet it&#8217;s flexible enough (thanks to Ruby metaprogramming magic) to handle on the fly data projections and custom querying.</p>
<p>ActiveRecord works well when you&#8217;re working within the context it knows: table per entity data models. Once you move from that paradigm, ActiveRecord stops being quite as helpful. On a previous project, in a different life as a consultant, we were building what amounted to a master data management system with Ruby on Rails. As the data model grew in complexity to account for the vagaries of legacy applications, we had to abandon ActiveRecord on multiple occasions and work with straight SQL to retrieve the objects the way we needed. The limitations of the OO approach became readily apparent we moved outside of the OO paradigm and started working with relational data.</p>
<p>Are we talking the Active Record design pattern? In that case I can&#8217;t really comment. It&#8217;s a design pattern. If you implement it right, it works wonders. If you implement it poorly&#8230; Well, if you implement it poorly I&#8217;m likely to tell you that your code smells bad and then explain why.</p>
<h4 id="nhibernate">NHibernate</h4>
<p>Nothing against NHibernate, I&#8217;m sure some people find it useful. I don&#8217;t. </p>
<p>There is a great deal of complexity in NHibernate. So much so, in fact, that I will do everything I can do avoid writing a speck of code for it.</p>
<p>Sure, you can tell me that I don&#8217;t have to write the XML mapping files and I can use Fluent NHibernate. I&#8217;ve done that. I&#8217;m still writing code to map from classes to tables. I can accomplish the same thing with boilerplate code and T4 to generate it. </p>
<p>But what about AutoMapper? AutoMapper solves simple problems. When you start creating complex mappings it starts getting trickier and you have to resort to writing the mappings yourself.</p>
<p>But what about Visual NHibernate? It&#8217;s a hot new tool that lets developers graphically design their table to object mappings in a GUI and then create the mapping files at the push of a button. Let me get this straight &#8211; you&#8217;re telling me that I should learn a tool to make my O/R-M tool easy to use because writing SQL is too hard/slow/requires sobriety? Let&#8217;s think about that for a minute:</p>
<ol>
<li>SQL is hard. I&#8217;ll grant you that it&#8217;s not easy. Neither is programming. Look at IoC containers and dependency injection.</li>
<li>Objects aren&#8217;t sets. I&#8217;ll grant you this one, too. A collection of objects bears no resemblance to a set.</li>
<li>We have a mismatch going on.</li>
<li>An O/R-M solves this problem (NHibernate, for the sake of example).</li>
<li>NHibernate mapping is painful.</li>
<li>Let&#8217;s use a tool because mapping is difficult and error prone.</li>
<li>The tool isn&#8217;t always right so we have to go back and fix our mappings.</li>
</ol>
<p>In order to ease the pain of mapping SQL statements to objects I have to learn two new technologies to obfuscate away the data persistence layer instead of learning how to correctly access data in the first place.</p>
<p>I trust you can sense my incredulity about the merits of this scenario and I&#8217;m going to move on.</p>
<h4 id="other_o_r_m_goes_here">Other O/R-M Goes Here</h4>
<p>I don&#8217;t know, unless I&#8217;ve listed it in this article I&#8217;ve probably never used it. But I see statements like this one: &#8220;I use (your O/R-M goes here) and it solves more problems than it creates.&#8221; </p>
<p>When you&#8217;re using a tool and you&#8217;re saying &#8220;Meh, it hasn&#8217;t killed <em>my</em> cat, yet,&#8221; I think it&#8217;s time that you rethink your strategy.</p>
<h4 id="other_language_goes_here">Other Language Goes Here</h4>
<p>I&#8217;m going to use Ruby as an example, because I know it and I love it. Ruby is a class based language. Just check out the code you write for a basic Ruby on Rails project:</p>
<pre><code>class Post &lt; ActiveRecord::Base
end
</code></pre>
<p>ZOMG! It&#8217;s a class! But, thanks to RubyMagic, Ruby is able to change the Post class at run time to look more like this:</p>
<pre><code>class Post &lt; ActiveRecord::Base
  attr_accessor :id, :title, :body, :created_at, :author
end
</code></pre>
<p>Shazam! It&#8217;s like I wrote it myself, but I didn&#8217;t and I didn&#8217;t have to map anything. Time for Fruity Pebbles.</p>
<p>When you get down to brass tacks, it&#8217;s only because of Ruby&#8217;s magical metaprogramming that a lot of the things I love about ActiveRecord are possible. Thankfully, the DLR should make a lot of this pseudo-magic readily available in the .NET Framework with the upcoming release of .NET 4.0. I don&#8217;t know about any other programming languages and how they intend (or if they intend) to make any kind of magical dynamic whizbangery available. The point is, dynamic whizbangery is neat. Dynamic whizbangery, when used properly, goes from being neat to being a productive tool that saves everyone a ton of time and effort.</p>
<h4 id="object_oriented_databases">Object-Oriented Databases</h4>
<p>I&#8217;ve never used something like <a target='_blank' href="http://db4o.com">db4o</a>, so I can&#8217;t comment on them directly. But what I can tell you is this: There is no way to easily query data from an OODB.   It requires complicated logic that is embedded in your data access libraries and, probably, is not available outside of your OO programming language. This effectively prevents the business users from hooking up Access or Excel to your OODB to run ad hoc reports. Instead you&#8217;ll have to write a complicated mapping process that pushes data on a regular basis from the OODB to an RDBMS for reporting purposes. You may end up doing this if you allow live ad hoc reporting against your production RDBMS. If you&#8217;re storing your data in a relational database, you can take advantage of SQL (which you&#8217;re probably already using) to move the data from the live production system to the reporting system.</p>
<p>OODBs do offer a seamless mapping between your code and your storage tier. There&#8217;s nothing to change because you&#8217;re storing native objects on disk. There is no O/R-M to hassle with. As I mentioned above, you&#8217;re going to need to create some kind of mechanism to export the data. db4o does contain functionality to do this. Or it claimed to the last time I looked into it. But, there are inherent difficulties in mapping OO code to relational storage mechanisms. Hell, that&#8217;s all we&#8217;ve been talking about for the last two thousand words.</p>
<h3 id="the_philosopher8217s_stone">The Philosopher&#8217;s Stone</h3>
<p>There is <a target='_blank' href="http://twitter.com/nkohari/statuses/6313196050">no single solution</a>. No alchemical, magickal, panacea or <a target='_blank' href="http://en.wikipedia.org/wiki/Philosopher%27s_stone">philosopher&#8217;s stone</a>. </p>
<p>I really wish that I had a great solution to this problem, but the fact is that you need to take the long view about your project. Are you willing to use an O/R-M and trade off your initial development speed for problems down the road? You&#8217;ll notice that I&#8217;m not naming any specific problems. Why? Because the problems you&#8217;re going to run into are, without a doubt, very different from the problems I&#8217;ve run into. They depend on the application you&#8217;re developing, the library you&#8217;re working with, and your experience with everything involved (the other developers, the codebase, the O/R-M, and your data model).</p>
<p>On the other hand, you could work with SQL and a thin abstraction layer and trade off initial development speed for a consistent long-term development pace. What does this require? Your developers will need to understand your OO language of choice, the data storage model, and SQL. That seems like a lot to ask but that&#8217;s how we do things at work. The developers who work with me on a daily basis understand the underlying data model. They understand .NET development. They know how to write SQL. Not just simple SQL, but they&#8217;re capable of writing fairly complex SQL. They didn&#8217;t show up on day one with these skills &#8211; we all had to learn. I know OO development well enough, I know SQL very well, and I learned the data model. </p>
<p>Commitment to doing your job well requires that you understand all facets of your work &#8211; the business, the data, and the applications that access it.</p>
<p><em>Note:</em> Any time I mention a specific technology or library, I&#8217;m not trying to knock it, I&#8217;m just pointing out an issue I&#8217;ve encountered.</p>
<h3 id="references">References</h3>
<p>We all owe a lot of thanks to Ted Neward for his great essay <a target='_blank' href="http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx">The Vietnam of Computer Science</a> and his follow up <a target='_blank' href="http://blogs.tedneward.com/2006/06/27/Thoughts+On+Vietnam+Commentary.aspx">Thoughts on Vietnam commentary</a></p>
<p>Martin Fowler&#8217;s <a target='_blank' href="http://www.amazon.com/gp/product/0321127420?ie=UTF8&amp;tag=facility9-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321127420"><em>Patterns of Enterprise Application Architecture</em></a><img src="http://www.assoc-amazon.com/e/ir?t=facility9-20&amp;l=as2&amp;o=1&amp;a=0321127420" width="1" height="1" border="0" alt="" style="border:none !important;margin:0px !important" /></p>
<p>Phil Haack&#8217;s <a target='_blank' href="http://haacked.com/archive/2006/06/29/WhyStoreYourDataInARelationalDatabase.aspx">Why Store Your Data in a Relational Databse</a></p>
<p>Jeff Atwood&#8217;s <a target='_blank' href="http://www.codinghorror.com/blog/archives/000621.html">Object-Relational Mapping is the Vietnam of Computer Science</a></p>
<p><a target='_blank' href="http://en.wikipedia.org/wiki/Object-relational_mapping">Object-Relational Mapping</a> Wikipedia FTW!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=-OO2ta-PqZI:ZwUb3Tz8O_Y:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=-OO2ta-PqZI:ZwUb3Tz8O_Y:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=-OO2ta-PqZI:ZwUb3Tz8O_Y:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=-OO2ta-PqZI:ZwUb3Tz8O_Y:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=-OO2ta-PqZI:ZwUb3Tz8O_Y:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=-OO2ta-PqZI:ZwUb3Tz8O_Y:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=-OO2ta-PqZI:ZwUb3Tz8O_Y:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/-OO2ta-PqZI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2010/01/05/or-ms-panacea-or-polio-braces/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://facility9.com/2010/01/05/or-ms-panacea-or-polio-braces</feedburner:origLink></item>
		<item>
		<title>Goals for 2010</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/kWOqC7JVy0c/goals-for-2010</link>
		<comments>http://facility9.com/2009/12/31/goals-for-2010#comments</comments>
		<pubDate>Thu, 31 Dec 2009 12:12:56 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[Professional Development]]></category>
		<category><![CDATA[nonsense]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[chainsaw hand]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[goats]]></category>
		<category><![CDATA[presenting]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sqljackass]]></category>
		<category><![CDATA[sqlpass]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1261</guid>
		<description><![CDATA[Thomas LaRock thought it would be fun to tag me in yet another round of blogging bingo, this time to answer the question &#8220;What are you Goals and Theme Word for 2010?&#8221;. To tell the truth, I have not made any kind of New Year&#8217;s Resolution for a number of years. I usually review my [...]]]></description>
			<content:encoded><![CDATA[<p>Thomas LaRock thought it would be fun to tag me in yet another round of blogging bingo, this time to answer the question <a href="http://thomaslarock.com/2009/12/2010-goals-and-themeword/">&#8220;What are you Goals and Theme Word for 2010?&#8221;</a>. To tell the truth, I have not made any kind of New Year&#8217;s Resolution for a number of years. I usually <a href="http://facility9.com/2009/09/14/your-own-personal-development-plan#what_are_your_goals">review my goals</a> on a regular basis, but let&#8217;s put them out here for everyone to see.</p>
<p>Theme word? I don&#8217;t have one, &#8220;f*%#ing rad&#8221; is two words, thank you very much.</p>
<h3 id="communication">Communication</h3>
<h4 id="become_a_better_writer">Become a Better Writer</h4>
<p>A long time ago, I went to college for four years, took out a bunch of loans, and got a degree in English, Non-Fiction Writing. I did exceptionally well in my English classes and did even better in the writing classes. I love writing and, frankly, the quality of my writing has not been up to par recently. I want to change my focus as a writer this year. I want to switch from writing short, highly technical, blog posts and change to creating longer article and essay length pieces. There&#8217;s nothing wrong with shorter, technical, posts but that is not where my interests lie. I want to focus on improving my writing so I can effectively teach more advanced concepts through writing as well as through public speaking. I was a good writer before and I&#8217;ll be a good writer again.</p>
<h4 id="become_a_better_presenter">Become a Better Presenter</h4>
<p>I have no doubts about my abilities as a presenter &#8211; I have a lot of room for improvement. Over the course of the year I&#8217;m going to team up with a number of people to improve my presentations. I want to get better at better content and delivery as well as meticulously practicing my presentations until I can deliver them in my sleep. I know that a lot of improvement comes from repetition and I would like to speak at least six times this year. With my current upcoming speaking schedule, that shouldn&#8217;t be difficult at all, but we&#8217;ll see.</p>
<h3 id="self_employment">Self-Employment</h3>
<p>I don&#8217;t intend to be self-employed by the end of 2010, but I plan on being well on my way. How am I going to get there?</p>
<h4 id="writing">Writing</h4>
<p>I&#8217;m writing stronger blog content. That&#8217;s not going to be enough. I want to get my name in a more places &#8211; magazines, guest blog posts, paid content, white papers, and a book. I&#8217;ve been shopping an idea around to various publishers and I&#8217;m hoping to have a book written and finished by the end of 2010. None of these things pay big bucks, but they all add to the bottom line.</p>
<h4 id="consulting">Consulting</h4>
<p>I haven&#8217;t done much consulting in the past, of course it was difficult when my day job was being a consultant &#8211; there&#8217;s an expectation that you will bring the business back to the company. Things have changed, I&#8217;m a full time employee now. My employer and I have had the talk &#8211; I&#8217;m allowed to do consulting work as long as I don&#8217;t help out our competitors. </p>
<p>This year I will take on several clients that require a small amount of time (10 &#8211; 20 hours each) every month. This isn&#8217;t to replace my existing job, this is to supplement it and provide additional income. Before I go completely solo, I want to have a substantial savings buffer built up and doing work on the side makes this a lot easier. I don&#8217;t plan on going at it alone &#8211; I&#8217;ve discussed this several co-conspirators and we have plans to get started this year.</p>
<h4 id="personal_ventures">Personal Ventures</h4>
<p>I have an idea for a business that will make me tens, maybe even hundreds, of dollars. I plan on fully pursuing this over the course of 2010. Honestly, I have incredibly high hopes for this business and we have already thought of multiple ways to monetize our business. That&#8217;s not to say that it&#8217;s sure to happen, I have a lot of hard work ahead me, but I&#8217;m looking forward to it.</p>
<h3 id="pass">PASS</h3>
<p>As many of you know, I was elected to the PASS Board of Directors and subsequently put in charge of the Summit program portfolio. This is the heart and soul of what I want to do over the next 12 months. I am going to make sure that the 2010 Summit program committee has my full support and that we&#8217;re can make the summit the best event possible.</p>
<h3 id="inky_mess">Inky Mess</h3>
<p>This is a personal one: I want to finish both full arm tattoo sleeves this year and, hopefully, start on my legs.</p>
<p>Once again, I think I&#8217;m supposed to pick victims. I&#8217;m going to pick <a href="http://ihumanable.com">Matt Nowack</a>, <a href="http://rickdoes.net">Rick Kierner</a>, <a href="http://jeffblankenburg.com/">Jeff Blankenburg</a>, and <a href="http://sqlchicken.com">Jorge Segarra</a></p>
<p>I also want a chainsaw on my hand like Bruce Campbell in Army of Darkness. That would be f*%#ing rad.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=kWOqC7JVy0c:w-OQANl0RyY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=kWOqC7JVy0c:w-OQANl0RyY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=kWOqC7JVy0c:w-OQANl0RyY:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=kWOqC7JVy0c:w-OQANl0RyY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=kWOqC7JVy0c:w-OQANl0RyY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=kWOqC7JVy0c:w-OQANl0RyY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=kWOqC7JVy0c:w-OQANl0RyY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/kWOqC7JVy0c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2009/12/31/goals-for-2010/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://facility9.com/2009/12/31/goals-for-2010</feedburner:origLink></item>
		<item>
		<title>Getting the ISO Week and Year</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/1TefOymccGc/getting-the-iso-week-and-year</link>
		<comments>http://facility9.com/2009/12/29/getting-the-iso-week-and-year#comments</comments>
		<pubDate>Tue, 29 Dec 2009 20:00:06 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[syndication]]></category>
		<category><![CDATA[goats]]></category>
		<category><![CDATA[hackery]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1254</guid>
		<description><![CDATA[Long story short: I need the ISO Week. We need to be able to make sure that when we&#8217;re reporting, we&#8217;re pulling data for the full week (which happens to coincide with ISO Week at my employer).
The problem with using an existing function is that the existing functions just return the week and not the [...]]]></description>
			<content:encoded><![CDATA[<p>Long story short: I need the ISO Week. We need to be able to make sure that when we&#8217;re reporting, we&#8217;re pulling data for the full week (which happens to coincide with ISO Week at my employer).</p>
<p>The problem with using an existing function is that the existing functions just return the week and not the full year + week combination. I used the function from the <a href='http://wiki.lessthandot.com/index.php/ISO_Week_In_SQL_Server' target='_blank'>Less Than Dot wiki</a> as a starting point and added my own code to create the full YYYYWW string to give me an ISO Week. This isn&#8217;t actually in the ISO standard format for reporting the ISO week, but I also don&#8217;t care so long as I can use the ISOWeek for effective querying.</p>
<p>Enjoy</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">FUNCTION</span> ISOweek <span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">DATE</span> <span style="color: #0000FF;">DATETIME</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">6</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span> 
  <span style="color: #0000FF;">BEGIN</span>
    <span style="color: #0000FF;">DECLARE</span> @ISOweek <span style="color: #0000FF;">INT</span>,
      @<span style="color: #0000FF;">YEAR</span> <span style="color: #0000FF;">INT</span>,
      @rVal <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">6</span><span style="color: #808080;">&#41;</span> ;
&nbsp;
&nbsp;
    <span style="color: #0000FF;">SET</span> @ISOweek <span style="color: #808080;">=</span> <span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>wk, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #000;">1</span> <span style="color: #808080;">-</span> <span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>wk, <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>yyyy, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">CHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #FF0000;">'0104'</span><span style="color: #808080;">&#41;</span> ;
    <span style="color: #0000FF;">SET</span> @<span style="color: #0000FF;">YEAR</span> <span style="color: #808080;">=</span> <span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>yyyy, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> ;
&nbsp;
    <span style="color: #0000FF;">SET</span> @rVal <span style="color: #808080;">=</span> <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">YEAR</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #0000FF;">RIGHT</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'00'</span> <span style="color: #808080;">+</span> <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span>@ISOWeek <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>, <span style="color: #000;">2</span><span style="color: #808080;">&#41;</span>
&nbsp;
    <span style="color: #008080;">--Special cases: Jan 1-3 may belong to the previous year</span>
    <span style="color: #0000FF;">IF</span> <span style="color: #808080;">&#40;</span>@ISOweek <span style="color: #808080;">=</span> <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> 
      <span style="color: #0000FF;">BEGIN</span>
        <span style="color: #0000FF;">SET</span> @rVal <span style="color: #808080;">=</span> dbo.<span style="color: #202020;">ISOweek</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>yyyy, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">-</span> <span style="color: #000;">1</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">CHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
                                   <span style="color: #808080;">+</span> <span style="color: #FF0000;">'12'</span>
                                   <span style="color: #808080;">+</span> <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span><span style="color: #000;">24</span> <span style="color: #808080;">+</span> <span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">DAY</span>, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">CHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
                                   <span style="color: #808080;">+</span> <span style="color: #000;">1</span> ;
      <span style="color: #0000FF;">END</span>
&nbsp;
    <span style="color: #008080;">--Special case: Dec 29-31 may belong to the next year</span>
    <span style="color: #0000FF;">IF</span> <span style="color: #808080;">&#40;</span>
        <span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>mm, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #000;">12</span><span style="color: #808080;">&#41;</span>
        <span style="color: #808080;">AND</span> <span style="color: #808080;">&#40;</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>dd, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">-</span> <span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>dw, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">&amp;</span>gt;<span style="color: #808080;">=</span> <span style="color: #000;">28</span><span style="color: #808080;">&#41;</span>
       <span style="color: #808080;">&#41;</span> 
      <span style="color: #0000FF;">BEGIN</span>
        <span style="color: #0000FF;">SET</span> @ISOweek <span style="color: #808080;">=</span> <span style="color: #000;">1</span> ;
        <span style="color: #0000FF;">SET</span> @<span style="color: #0000FF;">YEAR</span> <span style="color: #808080;">=</span> <span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>yyyy, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #000;">1</span> ;
&nbsp;
        <span style="color: #0000FF;">SET</span> @rVal <span style="color: #808080;">=</span> <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">DATEPART</span><span style="color: #808080;">&#40;</span>yyyy, @<span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #000;">1</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #FF0000;">'01'</span>
      <span style="color: #0000FF;">END</span>
&nbsp;
    <span style="color: #0000FF;">RETURN</span> @rVal ;
  <span style="color: #0000FF;">END</span>
GO</pre></div></div>

<p>This lets me do some snazzy reporting hackery like this:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>  <span style="color: #FF00FF;">MIN</span><span style="color: #808080;">&#40;</span>c2.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> StartDate,
        <span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#40;</span>c2.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> EndDate
<span style="color: #0000FF;">FROM</span>    dbo.<span style="color: #202020;">Calendar</span> <span style="color: #0000FF;">AS</span> c
        <span style="color: #0000FF;">INNER</span> <span style="color: #808080;">JOIN</span> dbo.<span style="color: #202020;">Calendar</span> <span style="color: #0000FF;">AS</span> c2 <span style="color: #0000FF;">ON</span> c.<span style="color: #202020;">ISOWeek</span> <span style="color: #808080;">=</span> c2.<span style="color: #202020;">ISOWeek</span>
<span style="color: #0000FF;">WHERE</span>   c.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">DATE</span><span style="color: #808080;">&#93;</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">'20091229'</span> ;
&nbsp;
<span style="color: #008080;">/*
StartDate               EndDate
----------------------- -----------------------
2009-12-27 00:00:00.000 2010-01-02 00:00:00.000
*/</span></pre></div></div>

<p>Which is then used to feed report parameters.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=1TefOymccGc:m033ukUWssQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=1TefOymccGc:m033ukUWssQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=1TefOymccGc:m033ukUWssQ:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=1TefOymccGc:m033ukUWssQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=1TefOymccGc:m033ukUWssQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=1TefOymccGc:m033ukUWssQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=1TefOymccGc:m033ukUWssQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/1TefOymccGc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2009/12/29/getting-the-iso-week-and-year/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://facility9.com/2009/12/29/getting-the-iso-week-and-year</feedburner:origLink></item>
		<item>
		<title>Busy Busy Silence</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/_LprQNcDzKo/busy-busy-silence</link>
		<comments>http://facility9.com/2009/12/24/busy-busy-silence#comments</comments>
		<pubDate>Thu, 24 Dec 2009 13:37:30 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[nonsense]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1248</guid>
		<description><![CDATA[It&#8217;s time for a personal message from your friendly Director-Elect-at-Large.
In about a week, I&#8217;m going to be taking on my first year of duties as a Director-at-Large of PASS. What are those duties? I&#8217;m going to be overseeing the program efforts for the 2010 PASS Summit. I&#8217;ll be working closely with an established team of [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time for a personal message from your friendly Director-Elect-at-Large.</p>
<p>In about a week, I&#8217;m going to be taking on my first year of duties as a Director-at-Large of PASS. What are those duties? I&#8217;m going to be overseeing the program efforts for the 2010 PASS Summit. I&#8217;ll be working closely with an established team of volunteers to make the upcoming Summit an amazing experience for everyone.</p>
<p>Outside of PASS, what have I been doing?</p>
<p><strong>Writing</strong><br />
I have been working on an essay length blog post. I want to branch into writing longer, more-focused, articles here. I love the shorter posts, but sometimes I don&#8217;t have anything to write about. Sometimes I just want to focus my creative energy toward something that requires more effort from me. These longer articles give me a chance to be a bit more creative and exercise my creative powers.</p>
<p>It&#8217;s also nice to get back to one of my passions: writing. Long before I went to college, I had a passion for writing and a passion for the sciences. When I went to college I majored in English with a concentration in Non-Fiction Writing. My original goal was to go into technical writing. That didn&#8217;t happen. I had to feed myself, so I got a &#8220;real job.&#8221; It&#8217;s nearly ten years later and I&#8217;m confident in my knowledge and ideas and writing abilities. It&#8217;s time to start writing longer pieces.</p>
<p><strong>Working</strong><br />
For those of you how might not know, my client hired me on in November. They made me an offer a few days before I left to go to the PASS Summit and I accepted. This has been a big change for me. For the first time in 5 years I&#8217;m not a consultant &#8211; I am now responsible for the longevity of <em>our</em> data. With that added responsibility, I&#8217;m now the key decision maker for our databases (barring the budget, of course). In addition to my move onto the PASS Board and becoming a strategic thinker, I have to wear both tactical and strategic hats at work. It has been an interesting change and I&#8217;ve been fortifying the shop so I can do enjoyable things moving forward instead of plugging holes.</p>
<p><strong>Working&#8230; for myself</strong><br />
I&#8217;ve been working on several side projects. There&#8217;s very little to report. One of the projects is a loose idea that will be hashed out over the next year and will hopefully become something great. Watch this space for more. I should be able to announce another one in a few weeks. And, the third one&#8230;</p>
<p>Well, I&#8217;ve jumped headfirst into the world of software development, again. My friend, <a href='http://ihumanable.com/' target='_blank'>Matt Nowack</a>, and I (with some help from <a href='http://brentozar.com' target='_blank'>Brent Ozar</a>) have been collaborating for the last two weeks on a project. There&#8217;s not a lot to talk about, yet. But the change in technology stack has been interesting. Rather than use a Microsoft stack, we&#8217;re using <a href="http://rubyonrails.org" target='_blank'>Ruby on Rails</a>, a pair of Macs, <a href='http://macromates.com' target='_blank'>TextMate</a>, <a href='http://sqlite.org' target='_blank'>SQLite</a>, and <a href='http://github.org' target='_blank'>github</a> to work together on this project. It&#8217;s been a fun experience getting back into development and considering a different set of problems from the day to day issues of a DBA. What has really amazed me, though, is how well all of these different tools have come together so nicely to make our development experience painless.</p>
<p><strong>Restores</strong><br />
As an aside, I had the primary HDD in my laptop die not once, but twice, in the last few days. The first time it threw an error during a routine drive check that OS X thankfully performs. I had backups, so I booted the machine from the install DVD, plugged in my backup drive, and did a full restore with a low-level format. within 48 hours, the machine wasn&#8217;t booting and Seagate&#8217;s tools were reporting massive disk errors. Seagate&#8217;s tools also let me put in an RMA request through the tool itself and I have been informed that my new drive should be shipping soon. Meanwhile, I went down to a local computer emporium and purchased a new HDD. I threw it in the laptop (unformatted) and fired up the laptop with the install DVD in the drive once again. Within three hours I was up and running with a working copy of my laptop. I have never doubted the need to take regular, reliable, backups. After the events of the last several days, I am doubly convinced. Without backups, I would still be installing software right now.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=_LprQNcDzKo:6b96R-u-TRk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=_LprQNcDzKo:6b96R-u-TRk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=_LprQNcDzKo:6b96R-u-TRk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=_LprQNcDzKo:6b96R-u-TRk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=_LprQNcDzKo:6b96R-u-TRk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=_LprQNcDzKo:6b96R-u-TRk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=_LprQNcDzKo:6b96R-u-TRk:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/_LprQNcDzKo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2009/12/24/busy-busy-silence/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://facility9.com/2009/12/24/busy-busy-silence</feedburner:origLink></item>
		<item>
		<title>The PowerShell of the Future</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/Q8ROOWTdBvU/the-powershell-of-the-future</link>
		<comments>http://facility9.com/2009/12/15/the-powershell-of-the-future#comments</comments>
		<pubDate>Tue, 15 Dec 2009 14:00:01 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[syndication]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1237</guid>
		<description><![CDATA[PowerShell Today
Allen White recently presented for CBusPASS about PowerShell. First off, I&#8217;d like to say thanks to Allen for driving down from Canton, OH to speak in person. He took the time to stick around afterwards and chat about a bunch of things that were on user group members&#8217; minds.
Allen&#8217;s presentation covered the basics of [...]]]></description>
			<content:encoded><![CDATA[<h3 id="powershell_as_it_stands">PowerShell Today</h3>
<p><a href="http://sqlblog.com/blogs/allen_white/" target='_blank'>Allen White</a> recently presented for <a href="http://columbus.sqlpass.org" target='_blank'>CBusPASS</a> about PowerShell. First off, I&#8217;d like to say thanks to Allen for driving down from Canton, OH to speak in person. He took the time to stick around afterwards and chat about a bunch of things that were on user group members&#8217; minds.</p>
<p>Allen&#8217;s presentation covered the basics of PowerShell through concrete examples &#8211; automating backups, restores, and database creation. Throughout the entire process, Allen demonstrated many aspects of PowerShell that make the DBA&#8217;s life easier. Allen demonstrated how it&#8217;s possible to easily work with data from files, the registry, and SQL Server simultaneously through PowerShell. Many of these things would take a considerable amount of work with T-SQL, if they&#8217;re even possible at all.</p>
<p>Interestingly, one of the first things I was reminded of was how much PowerShell looks like a variety of programming languages, specifically Perl. One of the nicest aspects of Perl is that it&#8217;s a glue language. Glue languages help you piece together various pieces and parts of your servers that have no real way to communicate with each other. PowerShell makes it possible to do the same thing, natively, on Windows.</p>
<p>PowerShell, as part of the Common Engineering Criteria, is enabled in all of the newer Microsoft server products. So, you can be sure that PowerShell is available as part of SQL Server, Exchange Server, Windows Server 2008, SharePoint, and many other products that I&#8217;ve forgotten. This will make it easier to take care of a larger number of servers and diverse server products using a single language.</p>
<p>This is the state of PowerShell right now. PowerShell 2.0 is available with Windows 7 and Windows Server 2008 R2. </p>
<p>What&#8217;s really exciting is <a href='http://pash.sourceforge.net/' target='_blank'>PaSH</a>.</p>
<h3 id="powershell_tomorrow">PowerShell Tomorrow</h3>
<div id="attachment_1238" class="wp-caption alignright" style="width: 202px"><a href="http://facility9.com/files/2009/12/windows_mobile.png"><img src="http://facility9.com/files/2009/12/windows_mobile-192x300.png" alt="Object reference not set to an instance of a phone" title="windows_mobile" width="192" height="300" class="size-medium wp-image-1238" /></a><p class="wp-caption-text">Object reference not set to an instance of a phone</p></div>
<p>PaSH is an open source reimplementation of PowerShell for other operating systems &#8211; Linux, OS X, Windows Mobile. </p>
<p>Think about that for a minute&#8230; Did you really wait for 60 seconds to think about that? Good.</p>
<p>With PaSH I could VPN to my network, fire up my PowerShell prompt on my phone, and start diagnosing server problems. Or run a remote backup. Or failover a cluster. Or any number of wonderful and amazing things.</p>
<p>Here&#8217;s where it gets cooler: If PaSH catches on, we could soon see similar libraries for MySQL or Apache. Maybe someone will even write a layer that maps common Windows and SQL Server functionality to their open source equivalents. A heterogenous datacenter becomes a lot easier to manage when you can write maintenance scripts using a common language across all platforms.</p>
<p>Looking forward, this isn&#8217;t so far fetched. The open source community has embraced mono, the open source version of the .NET Framework &#8211; I have mono and MonoDevelop (the mono IDE) installed on my mac. It&#8217;s included in several Linux distributions by default. It isn&#8217;t that much of a stretch to imagine PaSH becoming an effective and accepted cross-platform administrative scripting language.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=Q8ROOWTdBvU:ywHDneYETqk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=Q8ROOWTdBvU:ywHDneYETqk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=Q8ROOWTdBvU:ywHDneYETqk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=Q8ROOWTdBvU:ywHDneYETqk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=Q8ROOWTdBvU:ywHDneYETqk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=Q8ROOWTdBvU:ywHDneYETqk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=Q8ROOWTdBvU:ywHDneYETqk:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/Q8ROOWTdBvU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2009/12/15/the-powershell-of-the-future/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://facility9.com/2009/12/15/the-powershell-of-the-future</feedburner:origLink></item>
		<item>
		<title>What is Your Biggest Weakness?</title>
		<link>http://feedproxy.google.com/~r/facility9/~3/lH7jSrSzubU/what-is-your-biggest-weakness</link>
		<comments>http://facility9.com/2009/12/09/what-is-your-biggest-weakness#comments</comments>
		<pubDate>Wed, 09 Dec 2009 18:00:34 +0000</pubDate>
		<dc:creator>Jeremiah Peschka</dc:creator>
				<category><![CDATA[Professional Development]]></category>
		<category><![CDATA[nonsense]]></category>

		<guid isPermaLink="false">http://facility9.com/?p=1230</guid>
		<description><![CDATA[David Stein started a fun little game of blog tag and zapped Brent Ozar who, in turn, zapped me. The challenge here is to answer the interview question &#8220;What is your biggest weakness?&#8221; David&#8217;s answer was that he loves to jump straight into code. Brent&#8217;s answer is that he only wants to do things that [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.made2mentor.com/2009/12/%E2%80%9Cwhat-is-your-biggest-weakness%E2%80%9D-the-classic-interview-question/' target='_blank'>David Stein</a> started a fun little game of blog tag and zapped <a href='http://www.brentozar.com/archive/2009/12/what-is-your-biggest-weakness/' target='_blank'>Brent Ozar</a> who, in turn, zapped me. The challenge here is to answer the interview question &#8220;What is your biggest weakness?&#8221; David&#8217;s answer was that he loves to jump straight into code. Brent&#8217;s answer is that he only wants to do things that he can do better than everyone else and only if he can do it quickly (Brent is what I call a Type A Slacker).</p>
<p>What&#8217;s my biggest weakness apart from a fondness for car keys and the gas pedal?</p>
<p>Well, there are two glaring flaws that come to mind. One is Brent&#8217;s raging flaw &#8211; if I don&#8217;t see myself as having any chance of being better than just about everyone, I don&#8217;t have a lot of interest in doing something.</p>
<p>As for my second flaw: if I&#8217;m going to do something and do it well, I&#8217;m also going to study that subject as if it were an academic subject. If I&#8217;m going to do it <em>and</em> I&#8217;m going to do it well, I&#8217;m going to understand why I&#8217;m doing it, how it works under the hood, and why it works that way. I will pursue the academic theory behind a subject thoroughly, sometimes far more than is necessary.</p>
<p>I love music. Over the course of my life, I have taken lessons in piano, guitar, and the french horn. I have taught myself the fundamentals of multiple percussion instruments, clarinet, and the fife. I&#8217;ve studied music theory formally in music classes and lessons and informally on my own. I&#8217;ve experimented with a variety of techniques to produce the sounds I want and have even taken apart and reassembled various musical instruments to gain a better understanding of their inner workings. Sounds like someone who likes music, right? Well, here&#8217;s the catch: I approached all of these instruments methodically, even though I wasn&#8217;t fully aware of it at the time. Ultimately, music became a passionate hobby: I knew that I would never be a great musician or composer. I didn&#8217;t have the drive or talent.</p>
<p>When I went to college I got a degree in English. I&#8217;ve always loved the written word. Rather than focus on analyzing literature, I studied the craft of writing. I read every book we were assigned on writing multiple times. I analyzed my favorite authors&#8217; writing styles. I pared down my writing and built it up in other styles. I challenged myself to write about subjects I had never written about. I studied writing the way that many people study math or science.</p>
<p>I&#8217;m very lucky that I&#8217;m in a career where I can go beyond my immediate tasks, look inside, and find the theory that makes it all tick. It sometimes takes a good tug to pull me back from the theory to focus on the practical. Thankfully, so much of database development is based on a thorough understanding of theory that it&#8217;s okay to go off on a tangent.</p>
<p>Who is next in this game of tag? <a href='http://ihumanable.com' target='_blank'>Matt Nowack</a>, and <a href='http://webbtechsolutions.com/blog/' target='_blank'>Joe Webb</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/facility9?a=lH7jSrSzubU:VzzhTe9N7q4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/facility9?i=lH7jSrSzubU:VzzhTe9N7q4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=lH7jSrSzubU:VzzhTe9N7q4:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/facility9?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=lH7jSrSzubU:VzzhTe9N7q4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/facility9?i=lH7jSrSzubU:VzzhTe9N7q4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/facility9?a=lH7jSrSzubU:VzzhTe9N7q4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/facility9?i=lH7jSrSzubU:VzzhTe9N7q4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/facility9/~4/lH7jSrSzubU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://facility9.com/2009/12/09/what-is-your-biggest-weakness/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://facility9.com/2009/12/09/what-is-your-biggest-weakness</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 18.210 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-02-06 17:40:31 --><!-- Compression = gzip -->
