<?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>Fiebert.com</title>
	<atom:link href="http://fiebert.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fiebert.com</link>
	<description>Andrew Fiebert is a database and web developer who believes that occasionally talking in the third person is an acceptable, necessary evil.</description>
	<lastBuildDate>Sun, 09 May 2010 15:50:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SQL interview question / brain teaser</title>
		<link>http://fiebert.com/sql-server/sql-interview-question-brain-teaser/</link>
		<comments>http://fiebert.com/sql-server/sql-interview-question-brain-teaser/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 23:57:04 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://fiebert.com/?p=191</guid>
		<description><![CDATA[I was asked this question a few months ago and liked it due to its simplicity, and how it can be done on paper which is how we&#8217;ve been administering our interview tests (this is currently not on my test). Imagine you have a packaging system and there is a table that defines what packages [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked this question a few months ago and liked it due to its simplicity, and how it can be done on paper which is how we&#8217;ve been administering our interview tests (this is currently not on my test).</p>
<p>Imagine you have a packaging system and there is a table that defines what packages a user can access.  There are two columns uid (user id) and pid (package id).  Every row in this table provides a specific user with access to a package, for example there may be rows [1,1] or [3,5] where as user 1 has access to package 1 or user 3 has access to package 5.  A user can have access to multiple packages which would result in rows like [1,1], [1,2], [1,3], etc&#8230;  However, a user will be considered a &#8220;Super User&#8221; if they have a pid of -1 assigned to their user id.  Often times a user is given access to multiple packages only to later be given &#8220;Super User&#8221; access.  Write a query for this table to display all user access however if a user is a &#8220;Super User&#8221;, only display the one row for them demonstrating that they are a &#8220;Super User&#8221;.</p>
<p>Now, more often then not people will come up with some hackish query involving &#8220;UNION&#8221; or &#8220;IN&#8221;.  When they do, tell them both are horrible for performance if not for any reason other then there are multiple executions within one query.  Ask them to try and rewrite it using joins and not &#8220;UNION&#8221; or &#8220;IN&#8221;.  This brain teaser is simple and should demonstrate their confidence with joins and ability to think beyond &#8220;Step 1, Step2&#8243; answers.  There is no one right answer, I&#8217;ve included mine below:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> a.uid, isnull<span class="br0">&#40;</span>b.vid,a.vid<span class="br0">&#41;</span> <span class="kw1">FROM</span> permissions <span class="kw1">AS</span> a<br />
<span class="kw1">LEFT</span> <span class="kw1">JOIN</span> <span class="br0">&#40;</span><span class="kw1">SELECT</span> uid, vid <span class="kw1">FROM</span> permissions <span class="kw1">WHERE</span> vid=<span class="nu0">-1</span><span class="br0">&#41;</span> <span class="kw1">AS</span> b<br />
<span class="kw1">ON</span> a.uid=b.uid</div>
]]></content:encoded>
			<wfw:commentRss>http://fiebert.com/sql-server/sql-interview-question-brain-teaser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Glacius</title>
		<link>http://fiebert.com/wordpress/glacius/</link>
		<comments>http://fiebert.com/wordpress/glacius/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 04:10:48 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[The Site]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress theme]]></category>

		<guid isPermaLink="false">http://fiebert.com/?p=171</guid>
		<description><![CDATA[So, I&#8217;ve spent a lot of time lately working with wordpress and it&#8217;s pretty awesome. I like it because it&#8217;s fully extensible and very easy to build on using just the theme alone (so you can move it later). I&#8217;ve totally redesigned / restructured the site from the last theme with high hopes that I [...]]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve spent a lot of time lately working with wordpress and it&#8217;s pretty awesome. I like it because it&#8217;s fully extensible and very easy to build on using just the theme alone (so you can move it later).  I&#8217;ve totally redesigned / restructured the site from the last theme with high hopes that I can make a solid foundation to build on in the future.  The theme is called Glacius in with being created in the winter and it is intended to be a minimalistic blog / portfolio / personal portal. </p>
<p>In the spirit of sharing, I&#8217;ve set up a <a href="http://fiebert.com/wordpress-themes-and-templates/">wordpress scripts page</a> where you can download Glacius and use it yourself.  It is far from complete and definitely messy still but hopefully that will change.</p>
]]></content:encoded>
			<wfw:commentRss>http://fiebert.com/wordpress/glacius/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Openrowset to gather disk usage</title>
		<link>http://fiebert.com/sql-server/using-openrowset-to-gather-disk-usage/</link>
		<comments>http://fiebert.com/sql-server/using-openrowset-to-gather-disk-usage/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 06:22:03 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[crawler]]></category>
		<category><![CDATA[openrowset]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://fiebert.com/?p=59</guid>
		<description><![CDATA[Lets jump into a practical example of openrowset in action. A common issue among dataservers is disk space so it only makes sense to monitor for thresholds so that you can fix an issue before it becomes an emergency. Thresholds are great, and you probably have an alerting tool like HP Service Center to take [...]]]></description>
			<content:encoded><![CDATA[<p>Lets jump into a practical example of openrowset in action.  A common issue among dataservers is disk space so it only makes sense to monitor for thresholds so that you can fix an issue before it becomes an emergency.  Thresholds are great, and you probably have an alerting tool like HP Service Center to take care of that for you.  However, what about trending and proactive issue resolution?</p>
<p>When you must maintain hundreds of machines, space trending is practically a requirement.  You will likely want to monitor (and trend) disk space on the database level as well, and we will get to that in a separate post.</p>
<p>We will work off of my openrowset disk space collector found on my scripts page <a href="http://fiebert.com/sql-server-scripts/p_get_drive_details/">HERE</a>.  This procedure is meant to be executed from your central data collection point and does not need to exist everywhere.</p>
<p>First, my approach toward the openrowset:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">SET</span> @LocalQuery = <span class="st0">&#8216; <br />
INSERT INTO #freeSpace <br />
SELECT * FROM <br />
OPENROWSET(&#8216;</span><span class="st0">&#8216;SQLNCLI&#8217;</span><span class="st0">&#8216;, &#8216;</span><span class="st0">&#8216;Server=&#8217;</span> + @RemoteInstance + <span class="st0">&#8216;;Trusted_Connection=yes;&#8217;</span><span class="st0">&#8216;,&#8217;</span><span class="st0">&#8221;</span> + @RemoteQuery + <span class="st0">&#8221;</span><span class="st0">&#8216;); &#8216;</span><br />
<span class="kw1">EXEC</span> master..sp_executesql @LocalQuery</div>
<p>Here, we figure we will try and keep everything as dynamic as possible.  The only real things we need to specify are the driver and that this will be a trusted connection.  We will construct the remote query dynamically in the code before openrowset and the remote instance will be passed into the instance upon execution (exec p_get_drive_details &#8216;HOSTNAME\INSTANCENAME&#8217;).</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">SET</span> @RemoteQuery = <span class="st0">&#8216;SET NOCOUNT ON; SET FMTONLY OFF; exec master..xp_fixeddrives&#8217;</span></div>
<p>To setup, first create a table drive_details with columns for: Date, InstanceName, DriveLetter, TotalMB, FreeMB</p>
<p>After that, create the procedure and run.  In our crawler, which we will discuss later, we can loop through all of our available instances (we will get into error checking later too).</p>
<p><strong>Bonus:</strong>  Create a view on top of your table called drive_details_recent and have it just show the last run.  This way we can have a history table for trending yet quickly look up the most recent info for either displaying on a front end or to just hide old data from view.</p>
]]></content:encoded>
			<wfw:commentRss>http://fiebert.com/sql-server/using-openrowset-to-gather-disk-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Openrowset Crawler Intro</title>
		<link>http://fiebert.com/sql-server/openrowset-crawler-intro/</link>
		<comments>http://fiebert.com/sql-server/openrowset-crawler-intro/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 15:10:58 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[crawler]]></category>
		<category><![CDATA[openrowset]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://fiebert.com/?p=33</guid>
		<description><![CDATA[So, I&#8217;m bored and I&#8217;m tired of looking at an empty blog, time to share some of the stuff I&#8217;ve learned (and built) over the past few years.  A lot of it will be DBA based but I&#8217;ve always been a developer at heart so they are tools to help you do the job quicker.  [...]]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;m bored and I&#8217;m tired of looking at an empty blog, time to share some of the stuff I&#8217;ve learned (and built) over the past few years.  A lot of it will be DBA based but I&#8217;ve always been a developer at heart so they are tools to help you do the job quicker.  I&#8217;m doing a lot of cooler database development work now so hopefully once I work though some backlog I&#8217;ll get to writing about more difficult things.</p>
<p>First, lets talk about a crawler briefly as most of the cool stuff I&#8217;ve done is based around data collection and storage.  I imagined a single data server being a central point for collecting data from all of the other data servers.  This works for most things in the database world, especially when you don&#8217;t have the luxury of pushing a service (application) to thousands of machines.  If you are into the service side, stay tuned, the team I just joined pushes data collection to a new level so hopefully I&#8217;ll get to shed some light on the concepts I&#8217;m learning.</p>
<p>Now, the central point without an application sitting on every machine can be achieved with openrowset because you can assume credentials between different SQL Servers on the same network (domain can of course be different).  This requires you to enable ad-hoc queries.  The way it is setup in SQL Server is beautiful because here you only have to enable openrowset on your crawler (central point of data collection) and you can leave the settings on the other thousand data servers alone.</p>
<div class="dean_ch" style="white-space: wrap;">sp_configure <span class="st0">&#8216;show advanced options&#8217;</span>, <span class="nu0">1</span><br />
reconfigure <span class="kw1">WITH</span> override<br />
go<br />
sp_configure <span class="st0">&#8216;Ad Hoc Distributed Queries&#8217;</span>, <span class="nu0">1</span><br />
reconfigure <span class="kw1">WITH</span> override<br />
go<br />
sp_configure <span class="st0">&#8216;show advanced options&#8217;</span>, <span class="nu0">0</span><br />
reconfigure <span class="kw1">WITH</span> override<br />
go</div>
<p>There, now we&#8217;ve opened the door.  The next step is to get the key (which you likely already have) to all the data servers.</p>
<p>Typically if you are managing even a couple hundred instances you will need a DBA functional group.  This is a windows domain group where you can stuff all the DBA accounts so this way, when you build out a new server, you just add that group and everyone has access.  We can the run the collection instance under one of those accounts and we have access everywhere (while obeying the domain account double-hop rule); OR we can create a common SQL authentication account everywhere and use that as the method to login everywhere.  Additionally we can do some tricks via BAT files, but we will talk about that another time.</p>
<p>There you have it, now you&#8217;re primed and ready to go.  Next post I&#8217;ll talk about the queries we can run to start collecting data.</p>
]]></content:encoded>
			<wfw:commentRss>http://fiebert.com/sql-server/openrowset-crawler-intro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
