<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MKDavies.com</title>
	<atom:link href="http://mkdavies.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mkdavies.com</link>
	<description>From the mind of Mike Davies</description>
	<lastBuildDate>Fri, 23 Mar 2012 14:43:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Guess my number for SQL Server</title>
		<link>http://mkdavies.com/2012/03/guess-my-number-for-sql-server/</link>
		<comments>http://mkdavies.com/2012/03/guess-my-number-for-sql-server/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 14:29:49 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=70</guid>
		<description><![CDATA[My Girls (8 and 10) and I wrote a &#8220;Guess my number&#8221; game in SQL this weekend.  Well, the truth is closer to I wrote it and they played with it.  Although this is quite simple, and often one of &#8230;<p class="read-more"><a href="http://mkdavies.com/2012/03/guess-my-number-for-sql-server/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>My Girls (8 and 10) and I wrote a &#8220;Guess my number&#8221; game in SQL this weekend.  Well, the truth is closer to I wrote it and they played with it.  Although this is quite simple, and often one of the first projects that a developer will create while learning a language, I will share my creation that took about 3 minutes to create.<span id="more-70"></span></p>
<p>[sql]SET NOCOUNT ON<br />
DECLARE @Guess TINYINT<br />
       ,@RandNum TINYINT<br />
       ,@Tries SMALLINT<br />
       ,@Message VARCHAR(200)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211; Enter your number here!<br />
SET @Guess = 90</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
IF OBJECT_ID(&#8216;tempdb..#randnum&#8217;) IS NULL<br />
BEGIN<br />
   Create table #randnum (randnum TINYINT,tries SMALLINT)<br />
   SET @RandNum = RAND() * 100<br />
   INSERT INTO #randnum VALUES (@RandNum,0)<br />
END<br />
ELSE<br />
BEGIN<br />
   SELECT @RandNum = randnum FROM #randnum<br />
END</p>
<p>UPDATE #randnum SET tries = tries + 1</p>
<p>IF @Guess = @RandNum<br />
BEGIN<br />
   SELECT @Tries = tries FROM #randnum<br />
   SET @Message = CAST(@Guess AS VARCHAR(5)) + &#8216; is right!&#8217; + CHAR(13) + CHAR(10)<br />
                + &#8216;You guessed my number in &#8216; + CAST(@tries AS VARCHAR(5)) + &#8216; tries.&#8217;<br />
   DROP TABLE #randnum<br />
END<br />
ELSE IF @Guess &gt; @RandNum<br />
   SET @Message = CAST(@Guess AS VARCHAR(5)) + &#8216; is too high!&#8217;<br />
ELSE IF @Guess &lt; @RandNum<br />
   SET @Message = CAST(@Guess AS VARCHAR(5)) + &#8216; is too low!&#8217;</p>
<p>RAISERROR(@Message,0,1) WITH NOWAIT[/sql]</p>
<p>That is it! nothing more to see here, just a quick little game!</p>
<p>Until next time,<br />
-Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2012/03/guess-my-number-for-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everyone is in customer service.</title>
		<link>http://mkdavies.com/2012/01/everyone-is-in-customer-service/</link>
		<comments>http://mkdavies.com/2012/01/everyone-is-in-customer-service/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 03:13:06 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=56</guid>
		<description><![CDATA[During one of my first jobs, my boss, also the company owner, said the following to me. Your job description is not your job.  Your job is to make the customer and the boss happy every day.  If that means &#8230;<p class="read-more"><a href="http://mkdavies.com/2012/01/everyone-is-in-customer-service/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>During one of my first jobs, my boss, also the company owner, said the following to me.</p>
<blockquote><p>Your job description is not your job.  Your job is to make the customer and the boss happy every day.  If that means answering phones or taking out the trash because it is what the company needs done at that moment, well, that is your job.</p></blockquote>
<p>Of course, this wasn&#8217;t aimed at any deficiencies that I had, or needs at that time, it was only a philosophical discussion about how to succeed anywhere.  In my lifetime, I have heard at least between 6-10 people say something along the lines of &#8220;No, I won&#8217;t/can&#8217;t do that, it isn&#8217;t my job.&#8221;  Whenever I was the customer on the end of that sentance, I don&#8217;t mind telling you that it pissed me off.<span id="more-56"></span></p>
<p>Sure, some people don&#8217;t have the skill/ability/certifications to do the work, and that is understandable.  But when you can get the job done, you have to put on that customer service hat and say &#8220;I&#8217;m not the best/most skilled/most experienced with this, but let me give it a shot and see if I can make you happy.&#8221;</p>
<p>My current job is somewhat devoid of a description, which as I have been saying, just doesn&#8217;t matter. However, when I find myself with almost no description, it brings me so much more freedom to try new things, and learn more in areas that I know little about!  For example, today I had 2 customers with urgent issues that i knew little about.  By taking the approach in the previous paragraph, I was able to get my hands dirty, learn about two systems I didn&#8217;t know much about, and resolve both issues.  And that isn&#8217;t even the best part!</p>
<p>For most of today, I also helped my boss with the reports he is responsible for, but needed assistance with.  My job description (again, pretty nonexistant) says nothing about helping him on his reports, but by understanding that he is the customer, I was able to make his day better and he gave me kudos in an email to his manager.  Now I have people who are higher up seeing my name linked to positive results, and am being offered more cool opportunities to make a difference in my company, and with this project.</p>
<p>All from acting like I am in customer service!</p>
<p>Until Next Time,<br />
-Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2012/01/everyone-is-in-customer-service/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The goat and the GOAT</title>
		<link>http://mkdavies.com/2011/12/the-goat-and-the-goat/</link>
		<comments>http://mkdavies.com/2011/12/the-goat-and-the-goat/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 22:47:44 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[GOAT]]></category>
		<category><![CDATA[Motivation]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=48</guid>
		<description><![CDATA[It is easy to be the goat.  Anyone can be singled out, and the blame can be laid.  We think it is a position that is random, but we put ourselves there by little things that build up in people&#8217;s &#8230;<p class="read-more"><a href="http://mkdavies.com/2011/12/the-goat-and-the-goat/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>It is easy to be the goat.  Anyone can be singled out, and the blame can be laid.  We think it is a position that is random, but we put ourselves there by little things that build up in people&#8217;s minds.  Maybe it is an action item that was missed, maybe it is a habit of clocking in right at the start time and not earlier.  Maybe it is defining your work purely by the job description you read when signing up for the job.  Know what?  The goat is rarely the GOAT.<span id="more-48"></span></p>
<p>It is hard to be the GOAT!  Very few have the passion, the determination, the resolve to do more than anyone else.  The GOAT will strive, working more than their share with aplomb.  The GOAT isn&#8217;t superhuman, for they negotiate for what they get, and have the statistics to back it up.  The GOAT is effective, is able to communicate, listens, and innovates.  No, the GOAT doesn&#8217;t tend to be the goat.</p>
<p>I will repeat that: The Greatest Of All Time does not tend to be the scapegoat.</p>
<p>Of course when I say the GOAT, I mean that person in your workplace who you know you can count on.  This person is working both harder and smarter.  This person went from the newbie to the leader quickly, and is improving the skill sets of everyone around them on a constant basis.  This is the person you go to when you want nothing less than success.</p>
<p>Are you the goat or the GOAT?  Are you bringing the passion and fire? Are you doing more than what your job description says?  Are you making everyone around you better?</p>
<p>If the answer is no, then why not?  Even if you have been the goat for years, it is never too late to become the GOAT.  It takes persistence and hard work, but in the end it is worth the price.</p>
<p>Start becoming the GOAT today.</p>
<p>Till next time,<br />
-Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2011/12/the-goat-and-the-goat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hit by a bus?</title>
		<link>http://mkdavies.com/2011/12/hit-by-a-bus/</link>
		<comments>http://mkdavies.com/2011/12/hit-by-a-bus/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 23:38:20 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=33</guid>
		<description><![CDATA[What would happen if you were hit by a bus?  Ok, let&#8217;s look past the physical ailments, or even death, but rather let&#8217;s look at how would it affect your microcosm? Who would be impacted?  Would your loved ones be &#8230;<p class="read-more"><a href="http://mkdavies.com/2011/12/hit-by-a-bus/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>What would happen if you were hit by a bus?  Ok, let&#8217;s look past the physical ailments, or even death, but rather let&#8217;s look at how would it affect your microcosm? Who would be impacted?  Would your loved ones be able to survive as well without you?  Would the support system that you have created for others to utilize fall apart?  What would your co-workers do?<span id="more-33"></span></p>
<p>I have been thinking about this a lot lately, and I will expand on that further another time.  To engage only one portion of the question, I think my coworkers would curse my name for the tidbits of subject area knowledge that I have never passed on.</p>
<p>We all have documentation of our processes as part of our job, but how many of us have every little thing written down?  I know I have done well, but can do better.  So for the next week or so, I will be looking to rectify this.  A way to provide my coworkers a way to maintain (and even improve) the systems that I have built and so if anything sudden were to happen, my friends who I work with every day would be minimally impacted.</p>
<p>It&#8217;s just a goal, but I think it is a real positive one!</p>
<p>Until next time,<br />
-Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2011/12/hit-by-a-bus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Seattle Seahawks and the power of winning each single game</title>
		<link>http://mkdavies.com/2011/11/the-seattle-seahawks-and-the-power-of-winning-a-single-game/</link>
		<comments>http://mkdavies.com/2011/11/the-seattle-seahawks-and-the-power-of-winning-a-single-game/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 01:23:31 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Sports]]></category>
		<category><![CDATA[Football]]></category>
		<category><![CDATA[Seahawks]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=21</guid>
		<description><![CDATA[Sunday marked the end of the Seattle Seahawks 2011 season. Not literally the end of their season, but rather the end of any playoff hopes they might have had. For the next few weeks they will only be playing to &#8230;<p class="read-more"><a href="http://mkdavies.com/2011/11/the-seattle-seahawks-and-the-power-of-winning-a-single-game/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Sunday marked the end of the Seattle Seahawks 2011 season. Not literally the end of their season, but rather the end of any playoff hopes they might have had. For the next few weeks they will only be playing to win single games, and all of the media will be talking about how each win reduces their draft status.<span id="more-21"></span></p>
<p>So as the discussions change from playoff hopes to draft debates, my mind wonders if it better to lose the rest of the season to get a higher pick, or is it more important to win each game? Is there anything that is owed the fans that go to each game, or is it more important to look to the future and the future fans the will be attending, and for that matter the future revenue having a better team generates. In my opinion you play to win every game no matter what your status in the draft is.</p>
<p>In football, some teams have no postseason chances from the start and are encouraged to throw games in order to &#8220;suck for luck&#8221;. But what about the enjoyment of every single game? What about the fans? What about the kids who live not for the draft, but for each individual game?</p>
<p>It is with this in mind that I suggest no team tank the season, even the Seahawks who seem to be completely out of it at this point barring some sort of miracle. Good players can be found anywhere in the draft as such quarterbacks like Aaron Rodgers and Tom Brady have shown.</p>
<p>So Seahawks, just win out the rest of your games! Even if you get a late draft pick, those wins will mean more to your fans and to the motivation of your players going into next season.</p>
<p>Till Next Time,<br />
-Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2011/11/the-seattle-seahawks-and-the-power-of-winning-a-single-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing With Hierarchies</title>
		<link>http://mkdavies.com/2011/11/playing-with-hierarchies/</link>
		<comments>http://mkdavies.com/2011/11/playing-with-hierarchies/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 23:27:03 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[HierarchyId]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=18</guid>
		<description><![CDATA[In our world of data, often times we come across data that represents a hierarchical structure.  I recently was asked to work on a design that would utilize the hierarchyid datatype that was introduced in SQL Server 2008. Our task &#8230;<p class="read-more"><a href="http://mkdavies.com/2011/11/playing-with-hierarchies/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>In our world of data, often times we come across data that represents a hierarchical structure.  I recently was asked to work on a design that would utilize the hierarchyid datatype that was introduced in SQL Server 2008.</p>
<p>Our task was to bulk load multiple nodes of a hierarchy into a single table structure, with the possibility of having multiple parents.  Since multiple parents are not supported in the hierarchyid datatype, I had some creative work ahead of me.</p>
<p><span id="more-18"></span></p>
<p>The first thing I needed to do was understand hierarchyid.  This datatype is meant to provide all of the information required to denote a &#8220;Single Parent&#8221; hierarchy.  However, the value displayed is a hexadecimal, and has no real world application.  Thankfully we have the following methods to help us.</p>
<ul type="disc">
<li>GetAncestor(n) -  This will get you parent hierarchyid at the level (int) that you supply</li>
<li>GetDescendant(child1, child2) &#8211; Gets the descendant of a hierarchyid based on the child hierarchyids you pass in. NOTE: this does not guarantee an unused hierarchyid</li>
<li>GetLevel() &#8211; This will return the level of the Hierarchyid.</li>
<li>hierarchyid::GetRoot() -  returns the root of a hierarchyid.  In my experience, this is always equivalent to &#8220;/&#8221;</li>
<li>IsDescendantOf() &#8211; Will return a bit value of 0 or 1 based on if the Hid is a descendant of the hierarchyid parameter.</li>
<li>hierarchyid::Parse(string) &#8211; Will return the hierarchyID of a string.  Ex: &#8216;/45/142/&#8217; returns 0xCBBE06F4.  This is the opposite of ToString.  Cast(&#8216;/45/142/&#8217; AS hierarchyid) performs the same action.</li>
<li>GetReparentedValue(oldparent, newparent) &#8211; This will exchange the old parent value for the new parent value.</li>
<li>ToString() &#8211; Will return the string representation of the hierarchyID.  Ex: 0xCBBE06F4 returns &#8216;/45/142/&#8217;.  This is the opposite of Parse.</li>
</ul>
<p>Since we have the ToString function and the hexadecimal value is hard to look at, I will refer to examples of hierarchyids with their string value.  After studying hierarchyid, I discovered a few related things.</p>
<p>First, the string representation of the hierarchyid is very intuitive with its structure.  /76/ is the parent of /76/39/, which in turn is the parent of /76/39/2/.</p>
<p>Second, I noticed that there is no function of this datatype that enforces any sort of integrity. A new record does not need to have its ancestors in the table.  There can be a single record in your table with a hierarchyid of /4/3/5/6/, and the 4, 3, and 5 hierarchies can be non existent.  In fact, if there is no unique constraint on the column, duplicate records with /4/3/5/6/ can exist in the same table.  It is in this way that hierarchyid is not really aware of the other nodes in the table.  Even great care must be taken with the GetDescendant function, because unlike an identity column, it will not just give you the next unused node.</p>
<p>Finally, given this information, I realized that the value represented in each node was completely arbitrary.  This means that it is another structure to store information in!</p>
<p>With this great piece of information in hand, I built a table similar to the following:</p>
<p>Existing tables: Country, SubCountry</p>
<div>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>CountryId</td>
<td>CountryName</td>
</tr>
<tr>
<td>206</td>
<td>United States</td>
</tr>
<tr>
<td>314</td>
<td>Canada</td>
</tr>
</tbody>
</table>
</div>
<div>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>SubCountryId</td>
<td>SubCountryName</td>
<td>CountryId</td>
</tr>
<tr>
<td>74</td>
<td>Washington</td>
<td>1</td>
</tr>
<tr>
<td>19</td>
<td>Oregon</td>
<td>1</td>
</tr>
<tr>
<td>261</td>
<td>British Columbia</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
<p>(hierarchyids are in string format)</p>
<div>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>GeographyId</td>
<td>GeographyHierarchyId</td>
<td>GeographyName</td>
</tr>
<tr>
<td>1</td>
<td>/206/</td>
<td>United States</td>
</tr>
<tr>
<td>2</td>
<td>/314/</td>
<td>Canada</td>
</tr>
<tr>
<td>3</td>
<td>/206/74/</td>
<td>Washington</td>
</tr>
<tr>
<td>4</td>
<td>/206/19/</td>
<td>Oregon</td>
</tr>
<tr>
<td>5</td>
<td>/314/261/</td>
<td>British Columbia</td>
</tr>
</tbody>
</table>
</div>
<p>In this fashion, the original IDs were preserved inside of the hierarchyid of the new structure, giving an easy way to update additional attributes that might be in the original table when the case arises.</p>
<p>So, how has your experience with hierarchyid been? Do you have any tricks or tips that have helped you out?</p>
<p>Until next time,<br />
-Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2011/11/playing-with-hierarchies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Goose!</title>
		<link>http://mkdavies.com/2011/11/goose/</link>
		<comments>http://mkdavies.com/2011/11/goose/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 22:54:00 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=11</guid>
		<description><![CDATA[Sometimes he is a pain, but I do love this silly cat.]]></description>
			<content:encoded><![CDATA[<p>Sometimes he is a pain, but I do love this silly cat.</p>
<div id="attachment_10" class="wp-caption alignnone" style="width: 630px"><a href="http://mkdavies.com/wp-content/uploads/2011/11/20111128-145120.jpg"><img class="size-large wp-image-10" title="Goose.jpg" src="http://mkdavies.com/wp-content/uploads/2011/11/20111128-145120-1024x768.jpg" alt="Goose" width="620" height="465" /></a><p class="wp-caption-text">Goose Sleeping</p></div>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2011/11/goose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting this blogging thing again&#8230;.</title>
		<link>http://mkdavies.com/2011/11/starting-this-blogging-thing-again/</link>
		<comments>http://mkdavies.com/2011/11/starting-this-blogging-thing-again/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 22:21:58 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://mkdavies.com/?p=5</guid>
		<description><![CDATA[Well, I&#8217;m starting this blogging thing again, we will see where it goes.  I just feel like I need an outlet for all the things in my head, no matter if anyone ever reads it. Till Next Time, -Mike]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;m starting this blogging thing again, we will see where it goes.  I just feel like I need an outlet for all the things in my head, no matter if anyone ever reads it.</p>
<p>Till Next Time,<br />
-Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://mkdavies.com/2011/11/starting-this-blogging-thing-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

