<?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/"
	>

<channel>
	<title>SwampfoxSoft</title>
	<atom:link href="http://swampfoxsoft.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://swampfoxsoft.com/blog</link>
	<description></description>
	<pubDate>Sat, 20 Mar 2010 12:21:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Locked Databases</title>
		<link>http://swampfoxsoft.com/blog/?p=98</link>
		<comments>http://swampfoxsoft.com/blog/?p=98#comments</comments>
		<pubDate>Fri, 19 Mar 2010 13:12:12 +0000</pubDate>
		<dc:creator>Jonathan Moore</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[SQL]]></category>

		<category><![CDATA[Activity Monitor]]></category>

		<category><![CDATA[Connections]]></category>

		<category><![CDATA[multi_user]]></category>

		<category><![CDATA[single_user]]></category>

		<guid isPermaLink="false">http://swampfoxsoft.com/blog/?p=98</guid>
		<description><![CDATA[Every so often, I’ll run into a database that’s locked and I want to be able to change something about it and cannot.  One way to see what is using the database in question is to run the activity monitor in SQL SMS.  From the activity monitor, you can kill a process from this screen [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Every so often, I’ll run into a database that’s locked and I want to be able to change something about it and cannot.  One way to see what is using the database in question is to run the activity monitor in SQL SMS.  From the activity monitor, you can kill a process from this screen by right-clicking the process and selecting the “Kill Process” option.  Unfortunately, I’ve had a few cases where the connections are on timers, so the connections come right back and lock the database again and I get the locked message again.</p>
<p class="MsoNormal">However, there is a way around this.  By setting the database as a single user database and rolling back all opened transactions, you can allow yourself the time to make the changes needed.</p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: &quot;Courier New&quot;; color: blue;">alter</span><span style="font-size: 10.0pt; font-family: &quot;Courier New&quot;;"> <span style="color: blue;">database</span> &lt;Database Name&gt; <span style="color: blue;">set</span> <span style="color: blue;">single_user</span> <span style="color: blue;">with</span> <span style="color: blue;">rollback</span> <span style="color: blue;">immediate</span></span></p>
<p class="MsoNormal">After running the command above, you should see the following result:</p>
<p class="MsoNormal"><span style="font-size: 8.0pt; font-family: &quot;Courier New&quot;;">“Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.”</span></p>
<p class="MsoNormal">After this is ran, only 1 user can now be connected to your database.  Just remember, the single user that is connected at that time is the window (or ADO connection) that you run this statement from. If you close your connection, the single connection could be taken by another process.  So it’s probably best to have your changes ready in T-SQL to run after you run the statement to alter database to single user.  If you are just running this to close all open connections (and there isn’t some process that auto-reconnects), then you can just run the statement below to alter the database back.  All open connections (except the current window/connection you are in) were closed by the first statement.</p>
<p class="MsoNormal">Running this next alter statement sets the database to allow multiple users again.  Any connection that was closed by the first statement will remain closed.</p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: &quot;Courier New&quot;; color: blue;">alter</span><span style="font-size: 10.0pt; font-family: &quot;Courier New&quot;;"> <span style="color: blue;">database</span> &lt;Database Name&gt; <span style="color: blue;">set</span> <span style="color: blue;">multi_user</span> <span style="color: blue;">with</span> <span style="color: blue;">rollback</span> <span style="color: blue;">immediate</span></span></p>
<p class="MsoNormal">After the command runs successfully, you will see the following result:</p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: &quot;Courier New&quot;; color: blue;">“</span><span style="font-size: 8.0pt; font-family: &quot;Courier New&quot;;">Command(s) completed successfully.”</span></p>
<p class="MsoNormal">So if you ever run into an issue where a connection is keeping you from processing changes that need to be made, first try the activity monitor.  If the connection(s) still persists, setting the database to single_user is good way to lock out other connections as long as it is handled correctly.</p>
<p class="MsoNormal"><span style="font-size: 8.0pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://swampfoxsoft.com/blog/?feed=rss2&amp;p=98</wfw:commentRss>
		</item>
		<item>
		<title>Turning Off Database Constraints</title>
		<link>http://swampfoxsoft.com/blog/?p=95</link>
		<comments>http://swampfoxsoft.com/blog/?p=95#comments</comments>
		<pubDate>Tue, 19 Jan 2010 12:53:25 +0000</pubDate>
		<dc:creator>Jonathan Moore</dc:creator>
		
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://swampfoxsoft.com/blog/?p=95</guid>
		<description><![CDATA[Ever needed to run a sql statement on every single table in a database (like adding a LastUserChanged column or turning off constraints temporarily)?  Well, there’s a good stored procedure for doing this:
EXEC sp_msforeachtable
So say you need to change data around on a database but foreign keys are slowing you down?  You can [...]]]></description>
			<content:encoded><![CDATA[<p>Ever needed to run a sql statement on every single table in a database (like adding a LastUserChanged column or turning off constraints temporarily)?  Well, there’s a good stored procedure for doing this:</p>
<p>EXEC sp_msforeachtable</p>
<p>So say you need to change data around on a database but foreign keys are slowing you down?  You can turn off all the constraints on your database and then turn them back on when you’re done (and still make sure your data is good)</p>
<p>You could run ALTER TABLE NOCHECK CONSTRAINT all for each table you want to change.  Even better, you could just turn off all constraints:</p>
<p>EXEC sp_msforeachtable &#8220;ALTER TABLE ? NOCHECK CONSTRAINT all&#8221;</p>
<p>Then turn them all back on (with checking to make sure the data is fine):</p>
<p>EXEC sp_msforeachtable &#8220;ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all&#8221;</p>
<p>The stored procedure sp_msforeachtable will allow you to quickly make changes to all tables.</p>
]]></content:encoded>
			<wfw:commentRss>http://swampfoxsoft.com/blog/?feed=rss2&amp;p=95</wfw:commentRss>
		</item>
		<item>
		<title>SQL: With Rollup</title>
		<link>http://swampfoxsoft.com/blog/?p=48</link>
		<comments>http://swampfoxsoft.com/blog/?p=48#comments</comments>
		<pubDate>Tue, 10 Nov 2009 02:30:00 +0000</pubDate>
		<dc:creator>Jonathan Moore</dc:creator>
		
		<category><![CDATA[SQL]]></category>

		<category><![CDATA[aggregate]]></category>

		<category><![CDATA[group]]></category>

		<category><![CDATA[grouping]]></category>

		<category><![CDATA[WITH ROLLUP]]></category>

		<guid isPermaLink="false">http://swampfoxsoft.com/blog/?p=48</guid>
		<description><![CDATA[There have been many cases over the years where I have had to spew out data into some type of output for the user, from Crystal Reports to text files and straight output to a print source. Most of the time, the users wanted multiple data rows and then a summary row to go along [...]]]></description>
			<content:encoded><![CDATA[<p>There have been many cases over the years where I have had to spew out data into some type of output for the user, from Crystal Reports to text files and straight output to a print source. Most of the time, the users wanted multiple data rows and then a summary row to go along with it.</p>
<p>What that usually meant though was that I returned the data to the application and then as I was printing I would do any calculations that needed to be done (Sum / Max / Min / Average) and also have to look for the breaks between groups so I could show subtotals as well. This meant for every aggregate function I wanted to do, I had to have a corresponding Subtotal and Grand Total variable and continuously calculate the variables for each record.</p>
<p>Seems that I have been doing a lot more work than I needed to. With Rollup takes away a lot of the applications need to manipulate the data so that all you really have to do is display the output in the format the user is expecting. With Rollup allows the data to not only have the detail records, but summary records to go with those records.<br /><span id="more-48"></span><br />
How does the really change what I&#8217;m doing?  Well, let&#8217;s take a look at how I currently handle a situation and how it changes with With Rollup.</p>
<p>Four friends have decided to go out bowling and want to keep their score across four games.  At the end of the night, they want to know their Total Score, Highest Score, Lowest Score and Average Score across all four games.  They want these by each person, but for the group as well.  Paul goes with the group, but doesn&#8217;t actually bowl any while he&#8217;s there.  This following is the data to show how they bowled and will be used in the examples that follow.</p>
<table style= "padding-left: 10px;fontsize: 9px;" >
<tr>
<td><code><br />
DECLARE @Player TABLE(PlayerID INT IDENTITY, Name VARCHAR(30))</p>
<p>INSERT INTO @Player VALUES (&#8217;Chris&#8217;)<br />
INSERT INTO @Player VALUES (&#8217;Sam&#8217;)<br />
INSERT INTO @Player VALUES (&#8217;Alex&#8217;)<br />
INSERT INTO @Player VALUES (&#8217;Paul&#8217;)</p>
<p>DECLARE @Scores TABLE(ScoreID INT IDENTITY, PlayerID INT, Score BIGINT)</p>
<p>INSERT INTO @Scores VALUES (3, 170)<br />
INSERT INTO @Scores VALUES (1, 223)<br />
INSERT INTO @Scores VALUES (3, 187)<br />
INSERT INTO @Scores VALUES (1, 250)<br />
INSERT INTO @Scores VALUES (2, 195)<br />
INSERT INTO @Scores VALUES (1, 244)<br />
INSERT INTO @Scores VALUES (3, 148)<br />
INSERT INTO @Scores VALUES (3, 166)<br />
INSERT INTO @Scores VALUES (2, 195)<br />
INSERT INTO @Scores VALUES (1, 237)<br />
INSERT INTO @Scores VALUES (2, 212)<br />
INSERT INTO @Scores VALUES (2, 172)<br />
</code>
</td>
</tr>
</table>
<p>The simple way that I&#8217;d handle this in the past is just joining these values together and then dumping it out to the application.</p>
<table style= "padding-left: 10px;fontsize: 9px;" >
<tr>
<td>
<code><br />
SELECT 'PlayerName' = PLY.Name, SCR.Score<br />
FROM @Player PLY<br />
LEFT OUTER JOIN @Scores SCR<br />
ON PLY.PlayerID = SCR.PlayerID<br />
ORDER BY PLY.PlayerID<br />
</code>
</td>
</tr>
</table>
<table border =1 >
</tr>
<tr>
<td>Chris</td>
<td align=right>223</td>
</tr>
<tr>
<td>Chris</td>
<td align=right>250</td>
</tr>
<tr>
<td>Chris</td>
<td align=right>244</td>
</tr>
<tr>
<td>Chris</td>
<td align=right>237</td>
</tr>
<tr>
<td>Sam</td>
<td align=right>195</td>
</tr>
<tr>
<td>Sam</td>
<td align=right>195</td>
</tr>
<tr>
<td>Sam</td>
<td align=right>212</td>
</tr>
<tr>
<td>Sam</td>
<td align=right>172</td>
</tr>
<tr>
<td>Alex</td>
<td align=right>170</td>
</tr>
<tr>
<td>Alex</td>
<td align=right>187</td>
</tr>
<tr>
<td>Alex</td>
<td align=right>148</td>
</tr>
<tr>
<td>Alex</td>
<td align=right>166</td>
</tr>
<tr>
<td>Paul</td>
<td align=right>NULL</td>
</tr>
</table>
<p>The application would then figure out the Total, High, Low and Average Score for each person as well as the group. For this, we&#8217;d need 10 different variables (also would need the count so that we could average correctly) and each calculation is prone to mistakes in coding.  The application also has to compare current user to the user from the last record to know when to put in summary rows. To make life easier, we could just group the items together and return that after returning our detail records.</p>
<table style= "padding-left: 10px;fontsize: 9px;" >
<tr>
<td>
<code><br />
SELECT 'PlayerID' = PLY.PlayerID<br />
	, &#8216;PlayerName&#8217; = (SELECT P2.Name FROM @Player P2 WHERE P2.PlayerID = PLY.PlayerID)<br />
	, &#8216;TotalScore&#8217; = SUM(SCR.Score), &#8216;HighScore&#8217; = MAX(SCR.Score), &#8216;LowScore&#8217; = MIN(SCR.Score)<br />
	, &#8216;AverageScore&#8217; =  AVG(CONVERT(MONEY,SCR.Score))<br />
FROM @Player PLY<br />
LEFT OUTER JOIN @Scores SCR<br />
ON PLY.PlayerID = SCR.PlayerID <br />
GROUP BY PLY.PlayerID<br />
ORDER BY PLY.PlayerID<br />
</code>
</td>
</tr>
</table>
<table style="fontsize: 9px;" border =1 >
<tr>
<td align=right width = 67>PlayerId</td>
<td align=left width = 100>PlayerName</td>
<td align=right width = 67>TotalScore</td>
<td align=right width = 67>HighScore</td>
<td align=right width = 67>LowScore</td>
<td align=right width = 67>AverageScore</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>954</td>
<td align=right>250</td>
<td align=right>223</td>
<td align=right>238.5</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>774</td>
<td align=right>212</td>
<td align=right>172</td>
<td align=right>193.5</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>671</td>
<td align=right>187</td>
<td align=right>148</td>
<td align=right>167.67</td>
</tr>
<tr>
<td align=right>4</td>
<td>Paul</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
</tr>
</table>
<p></p>
<table style= "padding-left: 10px;fontsize: 9px;" >
<tr>
<td>
<code><br />
SELECT 'PlayerID' = NULL, 'PlayerName' = 'Total', 'TotalScore' = SUM(SCR.Score)<br />
	, &#8216;HighScore&#8217; = MAX(SCR.Score), &#8216;LowScore&#8217; = MIN(SCR.Score)<br />
	, &#8216;AverageScore&#8217; = AVG(CONVERT(MONEY,SCR.Score))<br />
FROM @Player PLY<br />
LEFT OUTER JOIN @Scores SCR<br />
ON PLY.PlayerID = SCR.PlayerID<br />
</code></td>
</tr>
</table>
<p></p>
<table style="fontsize: 9px;" border =1 >
<tr>
<td align=right width = 67>PlayerId</td>
<td align=left width = 100>PlayerName</td>
<td align=right width = 67>TotalScore</td>
<td align=right width = 67>HighScore</td>
<td align=right width = 67>LowScore</td>
<td align=right width = 67>AverageScore</td>
</tr>
<tr>
<td align=right>NULL</td>
<td>Total</td>
<td align=right width = 67>2399</td>
<td align=right width = 67>250</td>
<td align=right width = 67>148</td>
<td align=right width = 67>199.9166</td>
</tr>
<p></p>
<p>This way, we&#8217;ve gotten rid of calculations in the application, but now our application has 3 different sets of data.  It also has to know when to use which set of data.<br />
With Rollup simplifies all of this by allowing detail and summary data in the same set.</p>
<table style= "padding-left: 10px;fontsize: 9px;" >
<tr>
<td>
<code><br />
SELECT 'PlayerID' = PLY.PlayerID<br />
	, &#8216;PlayerName&#8217; = (SELECT P2.Name FROM @Player P2 WHERE P2.PlayerID = PLY.PlayerID)<br />
	, SCR.ScoreID, &#8216;TotalScore&#8217; = SUM(SCR.Score), &#8216;HighScore&#8217; = MAX(SCR.Score)<br />
	, &#8216;LowScore&#8217; = MIN(SCR.Score), &#8216;AverageScore&#8217; =  AVG(CONVERT(MONEY,SCR.Score))<br />
FROM @Player PLY<br />
LEFT OUTER JOIN @Scores SCR<br />
ON PLY.PlayerID = SCR.PlayerID<br />
GROUP BY PLY.PlayerID, SCR.ScoreID<br />
WITH ROLLUP<br />
</code></td>
</tr>
</table>
<p></p>
<table style="fontsize: 9px;" border =1 >
<tr>
<td align=right width = 67>PlayerId</td>
<td align=left width = 100>PlayerName</td>
<td align=right width = 67>ScoreID</td>
<td align=right width = 67>TotalScore</td>
<td align=right width = 67>HighScore</td>
<td align=right width = 67>LowScore</td>
<td align=right width = 67>AverageScore</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>2</td>
<td align=right>223</td>
<td align=right>223</td>
<td align=right>223</td>
<td align=right>223</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>4</td>
<td align=right>250</td>
<td align=right>250</td>
<td align=right>250</td>
<td align=right>250</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>6</td>
<td align=right>244</td>
<td align=right>244</td>
<td align=right>244</td>
<td align=right>244</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>10</td>
<td align=right>237</td>
<td align=right>237</td>
<td align=right>237</td>
<td align=right>237</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>NULL</td>
<td align=right>954</td>
<td align=right>250</td>
<td align=right>223</td>
<td align=right>238.5</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>5</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>9</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>11</td>
<td align=right>212</td>
<td align=right>212</td>
<td align=right>212</td>
<td align=right>212</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>12</td>
<td align=right>172</td>
<td align=right>172</td>
<td align=right>172</td>
<td align=right>172</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>NULL</td>
<td align=right>774</td>
<td align=right>212</td>
<td align=right>172</td>
<td align=right>193.5</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>1</td>
<td align=right>170</td>
<td align=right>170</td>
<td align=right>170</td>
<td align=right>170</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>3</td>
<td align=right>187</td>
<td align=right>187</td>
<td align=right>187</td>
<td align=right>187</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>7</td>
<td align=right>148</td>
<td align=right>148</td>
<td align=right>148</td>
<td align=right>148</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>8</td>
<td align=right>166</td>
<td align=right>166</td>
<td align=right>166</td>
<td align=right>166</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>NULL</td>
<td align=right>671</td>
<td align=right>187</td>
<td align=right>148</td>
<td align=right>167.67</td>
</tr>
<tr>
<td align=right>4</td>
<td>Paul</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
</tr>
<tr>
<td align=right>4</td>
<td>Paul</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
</tr>
<tr>
<td align=right>NULL</td>
<td>NULL</td>
<td align=right>NULL</td>
<td align=right>2399</td>
<td align=right>250</td>
<td align=right>148</td>
<td align=right>199.9166</td>
</tr>
</table>
<p>As we see with the data returned, there are some rows with a NULL ScoreID and one row with both a NULL ScoreID and a NULL PlayerID. The rows with a NULL ScoreID are summary rows that contains the aggregates of all the scores for a player. The row with both a NULL ScoreID and a NULL PlayerID is the summary row that contains the aggregates for all scores for all players.<br />
However, this means that we are relying on NULL comparisons to find which rows are summary rows.  To make this an easier check, we can add the GROUPING clause.</p>
<table style= "padding-left: 10px;fontsize: 9px;" >
<tr>
<td>
<code><br />
SELECT 'PlayerID' = PLY.PlayerID<br />
	, &#8216;PlayerName&#8217; = (SELECT P2.Name FROM @Player P2 WHERE P2.PlayerID = PLY.PlayerID)<br />
	, &#8216;ScoreGroup&#8217; = GROUPING(SCR.ScoreID), &#8216;PlayerGroup&#8217; = GROUPING(PLY.PlayerID)<br />
	, &#8216;TotalScore&#8217; = SUM(SCR.Score), &#8216;HighScore&#8217; = MAX(SCR.Score), &#8216;LowScore&#8217; = MIN(SCR.Score)<br />
	, &#8216;AverageScore&#8217; =  AVG(CONVERT(MONEY,SCR.Score))<br />
FROM @Player PLY<br />
LEFT OUTER JOIN @Scores SCR<br />
ON PLY.PlayerID = SCR.PlayerID<br />
GROUP BY PLY.PlayerID, SCR.ScoreID<br />
WITH ROLLUP<br />
</code></td>
</tr>
</table>
<p></p>
<table style="fontsize: 9px;" border =1 >
<tr>
<td align=right width = 67>PlayerId</td>
<td align=left width = 100>PlayerName</td>
<td align=right width = 67>ScoreGroup</td>
<td align=right width = 67>PlayerGroup</td>
<td align=right width = 67>TotalScore</td>
<td align=right width = 67>HighScore</td>
<td align=right width = 67>LowScore</td>
<td align=right width = 67>AverageScore</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>223</td>
<td align=right>223</td>
<td align=right>223</td>
<td align=right>223</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>250</td>
<td align=right>250</td>
<td align=right>250</td>
<td align=right>250</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>244</td>
<td align=right>244</td>
<td align=right>244</td>
<td align=right>244</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>237</td>
<td align=right>237</td>
<td align=right>237</td>
<td align=right>237</td>
</tr>
<tr>
<td align=right>1</td>
<td>Chris</td>
<td align=right>1</td>
<td align=right>0</td>
<td align=right>954</td>
<td align=right>250</td>
<td align=right>223</td>
<td align=right>238.5</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
<td align=right>195</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>212</td>
<td align=right>212</td>
<td align=right>212</td>
<td align=right>212</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>172</td>
<td align=right>172</td>
<td align=right>172</td>
<td align=right>172</td>
</tr>
<tr>
<td align=right>2</td>
<td>Sam</td>
<td align=right>1</td>
<td align=right>0</td>
<td align=right>774</td>
<td align=right>212</td>
<td align=right>172</td>
<td align=right>193.5</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>170</td>
<td align=right>170</td>
<td align=right>170</td>
<td align=right>170</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>187</td>
<td align=right>187</td>
<td align=right>187</td>
<td align=right>187</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>148</td>
<td align=right>148</td>
<td align=right>148</td>
<td align=right>148</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>166</td>
<td align=right>166</td>
<td align=right>166</td>
<td align=right>166</td>
</tr>
<tr>
<td align=right>3</td>
<td>Alex</td>
<td align=right>1</td>
<td align=right>0</td>
<td align=right>671</td>
<td align=right>187</td>
<td align=right>148</td>
<td align=right>167.67</td>
</tr>
<tr>
<td align=right>4</td>
<td>Paul</td>
<td align=right>0</td>
<td align=right>0</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
</tr>
<tr>
<td align=right>4</td>
<td>Paul</td>
<td align=right>1</td>
<td align=right>0</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
<td align=right>NULL</td>
</tr>
<tr>
<td align=right>NULL</td>
<td>NULL</td>
<td align=right>1</td>
<td align=right>1</td>
<td align=right>2399</td>
<td align=right>250</td>
<td align=right>148</td>
<td align=right>199.9166</td>
</tr>
</table>
<p>As you can now see, we now have 2 columns that contain a bit type to determine whether or not the row is a summary row. When the ScoreGroup is 1, you can expect this row to be a summary of scores for the group. If PlayerGroup is also 1, then the scores are summarized for all the scores for the all the players. We now have one set of data to work with and can easily output it from the application without having to do the summaries, keep up with current users or worry about how many records are in the set.<br />
With Rollup allows for SQL to handle a lot of the dirty work that I used to handcode.  Using SQL for this makes code cleaner and more consistent and just plain simpler.</p>
]]></content:encoded>
			<wfw:commentRss>http://swampfoxsoft.com/blog/?feed=rss2&amp;p=48</wfw:commentRss>
		</item>
		<item>
		<title>SQL</title>
		<link>http://swampfoxsoft.com/blog/?p=46</link>
		<comments>http://swampfoxsoft.com/blog/?p=46#comments</comments>
		<pubDate>Wed, 09 Sep 2009 12:11:09 +0000</pubDate>
		<dc:creator>Jonathan Moore</dc:creator>
		
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://swampfoxsoft.com/blog/?p=46</guid>
		<description><![CDATA[As a programmer and then later a developer at the job I have, I&#8217;ve always been someone that had to know a lot of different technologies. By this, I mean that I really have never been in able to focus on in any one technology.  I work for a small company that does custom [...]]]></description>
			<content:encoded><![CDATA[<p>As a programmer and then later a developer at the job I have, I&#8217;ve always been someone that had to know a lot of different technologies. By this, I mean that I really have never been in able to focus on in any one technology.  I work for a small company that does custom application development to suit the customers needs, so we adapt to them.  In my work, I use VB6, Crystal Reports (8, 8.5, 10, 11), Visual Basic.Net, C#, SQL, LLBLGen, ASP, etc, etc. On top of those responsibilities I also help with the Network and I run the phone system here.</p>
<p>After all these years though, I&#8217;ve always been drawn to one thing here at work, SQL Server.  I love designing databases and writing stored procedures.  So, I&#8217;m pushing deeper into MSSQL to learn everything I possibly can, big or small, to help me be better at what I do.  Thankfully, I&#8217;ve been pushed more into the database world lately, so now is the perfect opportunity to expand my SQL knowledge even further.</p>
<p>Basically, I&#8217;m stating this because I am going to start blogging about things I learn SQL-wise along the way, no matter how small.  I know it will be helpful to me but hopefully, I&#8217;ll be a help to someone else along the way as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://swampfoxsoft.com/blog/?feed=rss2&amp;p=46</wfw:commentRss>
		</item>
		<item>
		<title>The Realm</title>
		<link>http://swampfoxsoft.com/blog/?p=43</link>
		<comments>http://swampfoxsoft.com/blog/?p=43#comments</comments>
		<pubDate>Mon, 18 May 2009 12:28:21 +0000</pubDate>
		<dc:creator>Jonathan Moore</dc:creator>
		
		<category><![CDATA[Hardware]]></category>

		<category><![CDATA[Cisco]]></category>

		<category><![CDATA[Network Security]]></category>

		<guid isPermaLink="false">http://swampfoxsoft.com/blog/?p=43</guid>
		<description><![CDATA[Was looking up an article on Cisco Network Security and stumbled on their nifty little web series:  The Realm.
]]></description>
			<content:encoded><![CDATA[<p>Was looking up an article on Cisco Network Security and stumbled on their nifty little web series:  <a href="http://tinyurl.com/cozf3q">The Realm</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://swampfoxsoft.com/blog/?feed=rss2&amp;p=43</wfw:commentRss>
		</item>
		<item>
		<title>New Computer</title>
		<link>http://swampfoxsoft.com/blog/?p=36</link>
		<comments>http://swampfoxsoft.com/blog/?p=36#comments</comments>
		<pubDate>Fri, 15 May 2009 11:53:05 +0000</pubDate>
		<dc:creator>Jonathan Moore</dc:creator>
		
		<category><![CDATA[Hardware]]></category>

		<category><![CDATA[Misc]]></category>

		<category><![CDATA[Computer]]></category>

		<category><![CDATA[New Egg]]></category>

		<category><![CDATA[PC]]></category>

		<category><![CDATA[Vista]]></category>

		<guid isPermaLink="false">http://swampfoxsoft.com/blog/?p=36</guid>
		<description><![CDATA[Since I&#8217;m going to be studying for my SQL Exams (70-431 or 70-432, 70-433 and 70-448), I needed a new computer to run all the software I need to study (as well as for a little bit of gaming).  My old PC was purchased from Wal-Mart about 5 years ago, so it definitely has [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m going to be studying for my SQL Exams (70-431 or 70-432, 70-433 and 70-448), I needed a new computer to run all the software I need to study (as well as for a little bit of gaming).  My old PC was purchased from Wal-Mart about 5 years ago, so it definitely has seen better days.  I set up a computer on NewEgg and was actually shocked at the amount of power you can get for relatively cheap.  Here&#8217;s the specs on my new computer:</p>
<table>
<tr>
<td>Motherboard</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16813128380">GIGABYTE GA-EP43-UD3L LGA 775 Intel P43 ATX Intel Motherboard</a></td>
</tr>
<tr>
<td>CPU</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16819115206">Intel Core 2 Duo E7400 Wolfdale 2.8GHz LGA 775 65W Dual-Core Processor Model BX80571E7400</a></td>
</tr>
<tr>
<td>Memory</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16820145215">CORSAIR 4GB (2 x 2GB) 240-Pin DDR2 SDRAM DDR2 1066 (PC2 8500) Dual Channel Kit Desktop Memory</a></td>
</tr>
<tr>
<td>Hard Drive</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822136320">Western Digital Caviar Black WD5001AALS 500GB 7200 RPM 32MB Cache SATA 3.0Gb/s 3.5&#8243; Internal Hard Drive</a></td>
</tr>
<tr>
<td>Video</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16814150365">XFX GS250XYDFU GeForce GTS 250 512MB 256-bit GDDR3 PCI Express 2.0 x16 HDCP Ready Video Card</a></td>
</tr>
<tr>
<td>DVD Drive</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16827151173">SAMSUNG Black DVD Burner with LightScribe</a></td>
</tr>
<tr>
<td>Power</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16817341022">OCZ Fatal1ty OCZ550FTY 550W ATX12V / EPS12V SLI Ready CrossFire Ready Modular Active PFC Power Supply</a></td>
</tr>
<tr>
<td>Case</td>
<td><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16811233035">GIGABYTE GZ-X3BPD-500 Black 0.6mm SECC Steel ATX Mid Tower Computer Case</a></td>
</table>
<p>After putting the computer together and making sure that everything was working, I loaded Windows XP Media Center on it.  It took about a week to get all the software I needed on it and to get it configured the way I wanted.  It was a huge improvement over my old PC.  However, I was a little disappointed that XP Media Center wasn&#8217;t using all 4 gigs of RAM due to it being 32-bit.</p>
<p>The Lord works in mysterious ways.  I attended the <a href="http://www.pdanug.net/">PDANUG</a> and at the end they gave out some door prizes.  The prize that I won just happened to be exactly what I needed:  Windows Vista Ultimate, 32-bit AND 64-bit.  So I&#8217;ve got my PC loaded with it now, running like a dream on all 4 Gb of RAM!</p>
]]></content:encoded>
			<wfw:commentRss>http://swampfoxsoft.com/blog/?feed=rss2&amp;p=36</wfw:commentRss>
		</item>
		<item>
		<title>Development Blog</title>
		<link>http://swampfoxsoft.com/blog/?p=32</link>
		<comments>http://swampfoxsoft.com/blog/?p=32#comments</comments>
		<pubDate>Thu, 14 May 2009 16:01:54 +0000</pubDate>
		<dc:creator>Jonathan Moore</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[42 Roads Microsoft SQL Server Development]]></category>

		<guid isPermaLink="false">http://swampfoxsoft.com/blog/?p=32</guid>
		<description><![CDATA[This is now strictly a development blog, focusing on Microsoft SQL Server.  My personal blog has moved to 42 Roads to Walk.
]]></description>
			<content:encoded><![CDATA[<p>This is now strictly a development blog, focusing on Microsoft SQL Server.  My personal blog has moved to <a href="http://www.42roads.net/blog/">42 Roads to Walk</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://swampfoxsoft.com/blog/?feed=rss2&amp;p=32</wfw:commentRss>
		</item>
	</channel>
</rss>
