<?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>Dev Team Assemble &#187; SQL Server</title>
	<atom:link href="http://www.calvinirwin.net/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.calvinirwin.net</link>
	<description>Evil beware!</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:42:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server Recovery Model &#8211; Modification Script</title>
		<link>http://www.calvinirwin.net/2011/10/20/sql-server-recovery-model-modification-script/</link>
		<comments>http://www.calvinirwin.net/2011/10/20/sql-server-recovery-model-modification-script/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 15:59:41 +0000</pubDate>
		<dc:creator>Calvin</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[moss 2007]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://www.calvinirwin.net/?p=298</guid>
		<description><![CDATA[I often find in my sharepoint development environments that I have issues with transaction logs filling up.  This gives me the "Error" page with no indication of what the problem is...yes I can go and change the &#60;customErrors&#62; tag to set the customer errors mode to off and add the callstack to the page [...]]]></description>
			<content:encoded><![CDATA[<p>I often find in my sharepoint development environments that I have issues with transaction logs filling up.  This gives me the "Error" page with no indication of what the problem is...yes I can go and change the &lt;customErrors&gt; tag to set the customer errors mode to off and add the callstack to the page but it still doesn't address the problem.  I whipped this script up because the dev sql server we are using has well over a hundred db's on it and I didn't fell like manually typing the ALTER DATABASE [xxx] SET RECOVERY SIMPLE for each one or doing the clickity click thing either.  Now the solution below probably breaks lots of best practices and such but it works for what I wanted it to do....which is modify all existing db's recovery mode.  To modify new db's recovery mode, just set the model db's option to simple and voila..you are ready to go.
</p>
<p>
Quick note: <strong>YOU PROBABLY DO NOT WANT TO EVER...I MEAN EVER...USE THIS ON A PRODUCTION SYSTEM.</strong>
</p>
<p><code language='sql'><br />
*/</p>
<p>	Modify th recovery model for all databases on your server</p>
<p>*/</p>
<p>	DECLARE @lasterror int</p>
<p>	DECLARE @sql nvarchar(max)</p>
<p>	DECLARE @dbname nvarchar(100)</p>
<p>	DECLARE @dbid int</p>
<p>	DECLARE @recModel int</p>
<p>	-- cycle the log</p>
<p>	exec sp_cycle_errorlog </p>
<p>	CREATE Table #dbInfo</p>
<p>	(</p>
<p>		database_id int NOT NULL,</p>
<p>		dbName nvarchar(100) NOT NULL,</p>
<p>		recoveryModel int</p>
<p>	)</p>
<p>	--SELECT database_id, [name], recovery_model FROM sys.databases order by database_id</p>
<p>	SELECT TOP 1 @dbid = database_id FROM sys.databases where database_id > 4  ORDER BY database_id asc;</p>
<p>	SELECT @dbname = [name] FROM sys.databases where database_id = @dbid;</p>
<p>	SELECT @recModel = recovery_model FROM sys.databases where database_id = @dbid;</p>
<p>	-- begin backup process</p>
<p>	WHILE @dbid > 0</p>
<p>	BEGIN</p>
<p>		INSERT INTO #dbInfo (database_id, dbName, recoveryModel) VALUES (@dbid, @dbname, @recModel);</p>
<p>		IF @recModel = 1</p>
<p>		BEGIN</p>
<p>			SELECT @sql = 'ALTER DATABASE [' + @dbname + '] SET RECOVERY SIMPLE'</p>
<p>			EXEC sp_executesql @sql</p>
<p>			SELECT @lasterror = @@ERROR</p>
<p>			IF @lasterror <> 0</p>
<p>				-- log the error to the message console</p>
<p>				PRINT 'ERROR: Changing the recovery mode for database : ' + @dbname + ' with error number ' + CAST(@lasterror as nvarchar(25))</p>
<p>			ELSE</p>
<p>				PRINT 'Recovery mode changed to simple (3) for database : ' + @dbname</p>
<p>		END</p>
<p>		-- get a new record</p>
<p>		SELECT @dbid = 0;</p>
<p>		SELECT TOP 1 @dbid =  database_id FROM sys.databases where database_id > 4 and</p>
<p>			database_id NOT IN (SELECT DISTINCT x.database_id FROM #dbInfo x);</p>
<p>		SELECT @dbname = [name] FROM sys.databases where database_id = @dbid;</p>
<p>		SELECT @recModel = recovery_model FROM sys.databases where database_id = @dbid;</p>
<p>	END	</p>
<p>	DROP Table #dbInfo</p>
<p>	SELECT database_id, [name], recovery_model FROM sys.databases order by database_id</p>
<p>	GO</p>
<p></code></p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/Configuration' rel='tag' target='_self'>Configuration</a>, <a class='technorati-link' href='http://technorati.com/tag/Development' rel='tag' target='_self'>Development</a>, <a class='technorati-link' href='http://technorati.com/tag/moss+2007' rel='tag' target='_self'>moss 2007</a>, <a class='technorati-link' href='http://technorati.com/tag/SharePoint' rel='tag' target='_self'>SharePoint</a>, <a class='technorati-link' href='http://technorati.com/tag/SQL+Server' rel='tag' target='_self'>SQL Server</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.calvinirwin.net/2011/10/20/sql-server-recovery-model-modification-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SELECT TOP n ROWS &#8211; DB2</title>
		<link>http://www.calvinirwin.net/2009/12/15/select-top-n-rows-db2/</link>
		<comments>http://www.calvinirwin.net/2009/12/15/select-top-n-rows-db2/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 13:53:17 +0000</pubDate>
		<dc:creator>Calvin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[DB2]]></category>

		<guid isPermaLink="false">http://www.calvinirwin.net/?p=243</guid>
		<description><![CDATA[One thing I always seem to forget when moving from one db system to the other (not using DB2 all that often) is how to select the TOP n rows from a query.
In MS SQL Server this is expressed as SELECT TOP n * FROM [table] ...
the equivilent in DB2 is SELECT * FROM [table] FETCH [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I always seem to forget when moving from one db system to the other (not using DB2 all that often) is how to select the TOP n rows from a query.</p>
<p>In MS SQL Server this is expressed as SELECT TOP n * FROM [table] ...</p>
<p>the equivilent in DB2 is SELECT * FROM [table] FETCH FIRST n ROWS ONLY</p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/DB2' rel='tag' target='_self'>DB2</a>, <a class='technorati-link' href='http://technorati.com/tag/SQL+Server' rel='tag' target='_self'>SQL Server</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.calvinirwin.net/2009/12/15/select-top-n-rows-db2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Shrink Logs and Custom Backup Script</title>
		<link>http://www.calvinirwin.net/2009/08/24/sql-server-shrink-logs-and-custom-backup-script/</link>
		<comments>http://www.calvinirwin.net/2009/08/24/sql-server-shrink-logs-and-custom-backup-script/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 17:07:24 +0000</pubDate>
		<dc:creator>Calvin</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[DBCC Shinkfile]]></category>
		<category><![CDATA[logfile]]></category>
		<category><![CDATA[shink]]></category>
		<category><![CDATA[sql server 2005]]></category>

		<guid isPermaLink="false">http://www.calvinirwin.net/?p=165</guid>
		<description><![CDATA[
