<?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>code.commongroove.com</title>
	<atom:link href="http://code.commongroove.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.commongroove.com</link>
	<description>C#, T-SQL, and general IT mojo</description>
	<lastBuildDate>Wed, 25 Aug 2010 20:25:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>IT Toolbox: TechNet Magazine August 2010</title>
		<link>http://code.commongroove.com/2010/08/25/it-toolbox-technet-magazine-august-2010/</link>
		<comments>http://code.commongroove.com/2010/08/25/it-toolbox-technet-magazine-august-2010/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 20:24:47 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Microsoft TechNet]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=194</guid>
		<description><![CDATA[The new August 2010 IT Toolbox posts are on the TechNet Magazine site.]]></description>
			<content:encoded><![CDATA[<p>The new IT Toolbox posts are on the TechNet Magazine site. This month, I covered these 3 cool tools/utilities:</p>
<ul>
<li><strong>grepWin</strong>: Search files for text across your file system</li>
<li><strong>TeraCopy</strong>: Copy files faster</li>
<li><strong>Tunnelier SSH Client</strong>: Feature-full SSH client for Windows</li>
</ul>
<p>Check it out here and let me know what you think:</p>
<p><a title="TechNet Magazine Auguest 2010 IT Toolbox" href="http://technet.microsoft.com/en-us/magazine/ff899681.aspx" target="_blank">August 2010 IT Toolbox for TechNet Magazine</a></p>
<p>And, as always, if you have a suggestion for a product to cover, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/08/25/it-toolbox-technet-magazine-august-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL: Backup All User Databases</title>
		<link>http://code.commongroove.com/2010/08/18/t-sql-backup-all-user-databases/</link>
		<comments>http://code.commongroove.com/2010/08/18/t-sql-backup-all-user-databases/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 14:35:07 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=189</guid>
		<description><![CDATA[Here&#8217;s an easy, generic way to back up all user databases on a SQL Server instance: DECLARE @name VARCHAR&#40;50&#41; -- database name DECLARE @path VARCHAR&#40;256&#41; -- path for backup files DECLARE @fileName VARCHAR&#40;256&#41; -- filename for backup DECLARE @fileDate VARCHAR&#40;20&#41; -- used for file name SET @path = 'D:\localBackups\' -- has to be a local path [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an easy, generic way to back up all user databases on a SQL Server instance:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DECLARE @name VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">-- database name</span><br />
DECLARE @path VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">-- path for backup files</span><br />
DECLARE @fileName VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">-- filename for backup</span><br />
DECLARE @fileDate VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">-- used for file name</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> @path <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'D:<span style="color: #000099; font-weight: bold;">\l</span>ocalBackups<span style="color: #000099; font-weight: bold;">\'</span> -- has to be a local path<br />
<br />
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)<br />
<br />
DECLARE db_cursor CURSOR FOR<br />
SELECT name<br />
FROM master.dbo.sysdatabases<br />
WHERE name NOT IN ('</span>master<span style="color: #ff0000;">','</span>model<span style="color: #ff0000;">','</span>msdb<span style="color: #ff0000;">','</span>tempdb<span style="color: #ff0000;">')<br />
<br />
OPEN db_cursor<br />
FETCH NEXT FROM db_cursor INTO @name<br />
<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
SET @fileName = @path + @name + '</span>_<span style="color: #ff0000;">' + @fileDate + '</span><span style="color: #66cc66;">.</span>BAK<span style="color: #ff0000;">'<br />
BACKUP DATABASE @name TO DISK = @fileName<br />
<br />
FETCH NEXT FROM db_cursor INTO @name<br />
END<br />
<br />
CLOSE db_cursor<br />
DEALLOCATE db_cursor</span></div></div>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/08/18/t-sql-backup-all-user-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stored Procedure to Export a Table via BCP</title>
		<link>http://code.commongroove.com/2010/08/04/stored-procedure-to-export-a-table-via-bcp/</link>
		<comments>http://code.commongroove.com/2010/08/04/stored-procedure-to-export-a-table-via-bcp/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 19:18:28 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=170</guid>
		<description><![CDATA[If you are looking for a generic way to export table data via BCP, here&#8217;s how: CREATE PROCEDURE ExportDataViaBcp &#40;  @server VARCHAR&#40;100&#41; = '(local)',  @db VARCHAR&#40;100&#41;,  @dbtable VARCHAR&#40;100&#41;,    @file VARCHAR&#40;200&#41;,  @fmt_date INT = 121,  @fmt_decimal INT = 128,  @fmt_money INT = 1,  @fmt_float INT = NULL &#41; AS SET NOCOUNT ON -- sql that gets [...]]]></description>
			<content:encoded><![CDATA[<p>If you are looking for a generic way to export table data via BCP, here&#8217;s how:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;height:300px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">CREATE</span> PROCEDURE ExportDataViaBcp<br />
<span style="color: #66cc66;">&#40;</span><br />
 @server VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'(local)'</span><span style="color: #66cc66;">,</span><br />
 @db VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
 @dbtable VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>  <br />
 @file VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
 @fmt_date INT <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">121</span><span style="color: #66cc66;">,</span><br />
 @fmt_decimal INT <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">128</span><span style="color: #66cc66;">,</span><br />
 @fmt_money INT <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><br />
 @fmt_float INT <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">AS</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span><br />
<br />
<span style="color: #808080; font-style: italic;">-- sql that gets executed </span><br />
DECLARE @tmpSql VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">8000</span><span style="color: #66cc66;">&#41;</span> <br />
<br />
<span style="color: #808080; font-style: italic;">-- in case we have an error</span><br />
DECLARE @error VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;">-- USE the database</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> @tmpSql <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'USE '</span> <span style="color: #66cc66;">+</span> @db <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">';'</span><br />
PRINT @tmpSql<br />
EXEC<span style="color: #66cc66;">&#40;</span>@tmpSql<span style="color: #66cc66;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;">-- Make sure the (global) temp tables have been cleaned up</span><br />
<span style="color: #993333; font-weight: bold;">IF</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'tempdb..##export_temp'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
 <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ##export_temp<br />
<span style="color: #993333; font-weight: bold;">IF</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'tempdb..##export_temp2'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
 <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ##export_temp2<br />
<br />
<span style="color: #808080; font-style: italic;">-- Execute the use and the select</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> @tmpSql <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'SELECT * INTO ##export_temp FROM '</span> <span style="color: #66cc66;">+</span> @dbtable  <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">';'</span><br />
PRINT @tmpSql<br />
EXEC<span style="color: #66cc66;">&#40;</span>@tmpSql<span style="color: #66cc66;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;">-- Build 2 lists</span><br />
<span style="color: #808080; font-style: italic;">-- 1. column names</span><br />
<span style="color: #808080; font-style: italic;">-- 2. columns converted to nvarchar from their original type</span><br />
DECLARE<br />
 @columnNames VARCHAR<span style="color: #66cc66;">&#40;</span>MAX<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
 @columnConversions VARCHAR<span style="color: #66cc66;">&#40;</span>MAX<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span><br />
 @columnNames <span style="color: #66cc66;">=</span><br />
  COALESCE<span style="color: #66cc66;">&#40;</span>@columnNames <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">','</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">'['</span> <span style="color: #66cc66;">+</span> column_name <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">']'</span><span style="color: #66cc66;">,</span><br />
 @columnConversions <span style="color: #66cc66;">=</span><br />
  COALESCE<span style="color: #66cc66;">&#40;</span>@columnConversions  <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">','</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">'CONVERT(NVARCHAR(100),['</span> <span style="color: #66cc66;">+</span> column_name <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">']'</span> <span style="color: #66cc66;">+</span><br />
  CASE<br />
   WHEN data_type <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'NUMERIC'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'DECIMAL'</span><span style="color: #66cc66;">&#41;</span> THEN CASE WHEN @fmt_decimal <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> THEN <span style="color: #ff0000;">','</span> <span style="color: #66cc66;">+</span> CONVERT<span style="color: #66cc66;">&#40;</span>VARCHAR<span style="color: #66cc66;">,</span> @fmt_decimal<span style="color: #66cc66;">&#41;</span> ELSE <span style="color: #ff0000;">''</span> END<br />
   WHEN data_type <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'MONEY'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'SMALLMONEY'</span><span style="color: #66cc66;">&#41;</span> THEN CASE WHEN @fmt_money <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> THEN <span style="color: #ff0000;">','</span> <span style="color: #66cc66;">+</span> CONVERT<span style="color: #66cc66;">&#40;</span>VARCHAR<span style="color: #66cc66;">,</span> @fmt_money<span style="color: #66cc66;">&#41;</span> ELSE <span style="color: #ff0000;">''</span> END<br />
   WHEN data_type <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'DATETIME'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'SMALLDATETIME'</span><span style="color: #66cc66;">&#41;</span> THEN CASE WHEN @fmt_date <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> THEN <span style="color: #ff0000;">','</span> <span style="color: #66cc66;">+</span>  <span style="color: #66cc66;">+</span> CONVERT<span style="color: #66cc66;">&#40;</span>VARCHAR<span style="color: #66cc66;">,</span> @fmt_date<span style="color: #66cc66;">&#41;</span> ELSE <span style="color: #ff0000;">''</span> END<br />
   WHEN data_type <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'FLOAT'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'REAL'</span><span style="color: #66cc66;">&#41;</span> THEN CASE WHEN @fmt_float <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> THEN <span style="color: #ff0000;">','</span> <span style="color: #66cc66;">+</span>  <span style="color: #66cc66;">+</span> CONVERT<span style="color: #66cc66;">&#40;</span>VARCHAR<span style="color: #66cc66;">,</span> @fmt_float<span style="color: #66cc66;">&#41;</span> ELSE <span style="color: #ff0000;">''</span> END<br />
   ELSE <span style="color: #ff0000;">''</span><br />
  END <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">') AS ['</span> <span style="color: #66cc66;">+</span> column_name <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">']'</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> tempdb<span style="color: #66cc66;">.</span>INFORMATION_SCHEMA<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">COLUMNS</span><br />
<span style="color: #993333; font-weight: bold;">WHERE</span> table_name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'##export_temp'</span><br />
<br />
<span style="color: #808080; font-style: italic;">-- execute select query to insert data and column names into new temp table</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> @tmpSql <span style="color: #66cc66;">=</span><br />
  <span style="color: #ff0000;">'SELECT '</span> <span style="color: #66cc66;">+</span> @columnNames <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">' '</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">'INTO ##export_temp2 '</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">'FROM ( '</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">' SELECT '</span> <span style="color: #66cc66;">+</span> @columnConversions <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">', 2 AS tmpsort FROM ##export_temp '</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">' UNION ALL '</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">' SELECT '</span><span style="color: #ff0000;">''</span> <span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>@columnNames<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">','</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #ff0000;">', '</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'['</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">']'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">''</span><span style="color: #ff0000;">', 1 AS tmpsort '</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">' ) AS x '</span> <span style="color: #66cc66;">+</span><br />
  <span style="color: #ff0000;">' ORDER BY x.tmpsort; '</span>;<br />
<br />
PRINT @tmpSql<br />
EXEC<span style="color: #66cc66;">&#40;</span>@tmpSql<span style="color: #66cc66;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;">-- Execute the BCP to create the file</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> @tmpSql <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'bcp &quot;SELECT * FROM ##export_temp2&quot; queryout &quot;'</span> <span style="color: #66cc66;">+</span> @file <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&quot; -c -CRAW -t, -T -S'</span> <span style="color: #66cc66;">+</span> @server<br />
EXEC master<span style="color: #66cc66;">.</span>sys<span style="color: #66cc66;">.</span>xp_cmdshell @tmpSql<br />
<span style="color: #993333; font-weight: bold;">IF</span> @@ERROR &amp;gt; <span style="color: #cc66cc;">0</span><br />
BEGIN<br />
 <span style="color: #993333; font-weight: bold;">IF</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'##export_temp'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
  <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ##export_temp<br />
 <span style="color: #993333; font-weight: bold;">IF</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'##export_temp2'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
  <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ##export_temp2<br />
 <span style="color: #993333; font-weight: bold;">SELECT</span> @error <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'Couldn'</span><span style="color: #ff0000;">'t execute the bcp: '</span><span style="color: #ff0000;">''</span> <span style="color: #66cc66;">+</span> @tmpSql;<br />
 RAISERROR<span style="color: #66cc66;">&#40;</span>@error<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />
 <span style="color: #993333; font-weight: bold;">RETURN</span><br />
END<br />
<br />
<span style="color: #808080; font-style: italic;">-- Make sure the (global) temp tables have been cleaned up</span><br />
<span style="color: #993333; font-weight: bold;">IF</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'tempdb..##export_temp'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
 <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ##export_temp<br />
<span style="color: #993333; font-weight: bold;">IF</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'tempdb..##export_temp2'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
 <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ##export_temp2<br />
<br />
GO</div></div>
<p>This does use global temp tables as well as xp_cmdshell, but it also gets the job done. </p>
<p>This is a modified version of the suggestion found here:<br />
<a href="http://weblogs.sqlteam.com/mladenp/archive/2006/07/25/10771.aspx">http://weblogs.sqlteam.com/mladenp/archive/2006/07/25/10771.aspx</a></p>
<p>Thanks to them for actually doing the hard work!  I just cleaned it up and made it support varied column names.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/08/04/stored-procedure-to-export-a-table-via-bcp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IT Toolbox: TechNet Magazine July 2010</title>
		<link>http://code.commongroove.com/2010/07/26/it-toolbox-technet-magazine-july-2010/</link>
		<comments>http://code.commongroove.com/2010/07/26/it-toolbox-technet-magazine-july-2010/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 14:23:58 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Microsoft TechNet]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=165</guid>
		<description><![CDATA[The new IT Toolbox column has been posted to the TechNet Magazine website. This month, I covered 3 cool tools: PowerShell SSH Server: Secured remote management Genie Timeline Professional: Fire and forget backups StressLinux Project: Stress your new system builds Check it out and let me know what you think: July 2010 IT Toolbox for [...]]]></description>
			<content:encoded><![CDATA[<p>The new IT Toolbox column has been posted to the TechNet Magazine website. This month, I covered 3 cool tools:</p>
<ul>
<li><strong>PowerShell SSH Server</strong>: Secured remote management</li>
<li><strong>Genie Timeline Professional</strong>: Fire and forget backups</li>
<li><strong>StressLinux Project</strong>: Stress your new system builds</li>
</ul>
<p>Check it out and let me know what you think:</p>
<p><a title="TechNet Magazine July 2010 IT Toolbox" href="http://technet.microsoft.com/en-us/magazine/ff808410.aspx" target="_blank">July 2010 IT Toolbox for TechNet Magazine</a></p>
<p>As always, if you have a suggestion for a product to cover, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/07/26/it-toolbox-technet-magazine-july-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IT Toolbox: TechNet Magazine June 2010</title>
		<link>http://code.commongroove.com/2010/06/23/it-toolbox-technet-magazine-june-2010/</link>
		<comments>http://code.commongroove.com/2010/06/23/it-toolbox-technet-magazine-june-2010/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 14:59:56 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Microsoft TechNet]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=161</guid>
		<description><![CDATA[The new IT toolbox column has been posted to the TechNet Magazine website. This month, I covered 3 cool tools: Password Reset Pro: Simple web-based AD password management for end users PerfectDisk 11 Server Edition: Keep your server&#8217;s HDD arrays tuned up FastCopy: Copy files faster Check it out and let me know what you [...]]]></description>
			<content:encoded><![CDATA[<p>The new IT toolbox column has been posted to the <a title="TechNet Magazine" href="http://www.technetmagazine.com" target="_blank">TechNet Magazine</a> website.  This month, I covered 3 cool tools:</p>
<ul>
<li><strong>Password Reset Pro</strong>: Simple web-based AD password management for end users</li>
<li><strong>PerfectDisk 11 Server Edition</strong>: Keep your server&#8217;s HDD arrays tuned up</li>
<li><strong>FastCopy</strong>: Copy files faster</li>
</ul>
<p>Check it out and let me know what you think!</p>
<p><a title="June 2010 IT Toolbox for TechNet Magazine" href="http://technet.microsoft.com/en-us/magazine/ff770991.aspx" target="_blank">June 2010 IT Toolbox for TechNet Magazine</a></p>
<p>As always, if you have a suggestion for a product to cover, feel free to email me via <a href="mailto:tntools@microsoft.com">tntools@microsoft.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/06/23/it-toolbox-technet-magazine-june-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IT Toolbox: TechNet Magazine May 2010</title>
		<link>http://code.commongroove.com/2010/05/12/it-toolbox-technet-magazine-may-2010/</link>
		<comments>http://code.commongroove.com/2010/05/12/it-toolbox-technet-magazine-may-2010/#comments</comments>
		<pubDate>Wed, 12 May 2010 14:38:00 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Microsoft TechNet]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=158</guid>
		<description><![CDATA[The new IT toolbox column has been posted to the TechNet Magazine website. This month, I covered 2 useful tools: SmartDeploy Enterprise: Virtualized, simplified, and easy to manage system images Tweak7: Make Windows 7 run how you want it to run Check them out and let me know what you think! May 2010 IT Toolbox [...]]]></description>
			<content:encoded><![CDATA[<p>The new IT toolbox column has been posted to the <a title="TechNet Magazine" href="http://www.technetmagazine.com" target="_blank">TechNet Magazine</a> website. This month, I covered 2 useful tools:</p>
<ul>
<li><strong>SmartDeploy Enterprise</strong>: Virtualized, simplified, and easy to manage system images</li>
<li><strong>Tweak7</strong>: Make Windows 7 run how you want it to run</li>
</ul>
<p>Check them out and let me know what you think!</p>
<p><a title="May 2010 IT Toolbox for TechNet Magazine" href="http://technet.microsoft.com/en-us/magazine/ff679922.aspx" target="_blank">May 2010 IT Toolbox for TechNet Magazine</a></p>
<p>As always, if you have a suggestion for a product to cover, feel free to email me via <a href="mailto:tntools@microsoft.com">tntools@microsoft.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/05/12/it-toolbox-technet-magazine-may-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IT Toolbox: TechNet Magazine April 2010</title>
		<link>http://code.commongroove.com/2010/04/13/it-toolbox-technet-magazine-april-2010/</link>
		<comments>http://code.commongroove.com/2010/04/13/it-toolbox-technet-magazine-april-2010/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 01:33:21 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Microsoft TechNet]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=153</guid>
		<description><![CDATA[The new IT toolbox column has been posted to the TechNet Magazine website.  This month, I covered 3 cool tools: VirtualBox: Free and open source virtualization platform for Windows CPU-Z: Check out detailed stats on your CPU and memory with this free tool Prime95: Stress test your new PC or server before you let it [...]]]></description>
			<content:encoded><![CDATA[<p>The new IT toolbox column has been posted to the <a title="TechNet Magazine" href="http://www.technetmagazine.com" target="_blank">TechNet Magazine</a> website.  This month, I covered 3 cool tools:</p>
<ul>
<li><strong>VirtualBox</strong>: Free and open source virtualization platform for Windows</li>
<li><strong>CPU-Z</strong>: Check out detailed stats on your CPU and memory with this free tool</li>
<li><strong>Prime95</strong>: Stress test your new PC or server before you let it loose</li>
</ul>
<p>Check it out and let me know what you think!</p>
<p><a title="April 2010 IT Toolbox for TechNet Magazine" href="http://technet.microsoft.com/en-us/magazine/ff626495.aspx" target="_blank">April 2010 IT Toolbox for TechNet Magazine</a></p>
<p>As always, if you have a suggestion for a product to cover, feel free to email me via <a href="mailto:tntools@microsoft.com">tntools@microsoft.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/04/13/it-toolbox-technet-magazine-april-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickly Create Test Users on your Domain Controller</title>
		<link>http://code.commongroove.com/2010/04/07/quickly-create-test-users-on-your-domain-controller/</link>
		<comments>http://code.commongroove.com/2010/04/07/quickly-create-test-users-on-your-domain-controller/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 15:14:38 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Batch Files]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/?p=149</guid>
		<description><![CDATA[If you are looking for a quick way to create test users in your domain, you can do so through the old NET USER command.  You will have to run this on your domain controller&#8217;s command prompt.  The following will create 200k test users: for /l %i in &#40;1,1,200000&#41; do net user TestUser%i p@ssw0rd /domain [...]]]></description>
			<content:encoded><![CDATA[<p>If you are looking for a quick way to create test users in your domain, you can do so through the old NET USER command.  You will have to run this on your domain controller&#8217;s command prompt.  The following will create 200k test users:</p>
<div class="codecolorer-container dos default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00b100; font-weight: bold;">for</span> /l <span style="color: #33cc33;">%</span><span style="color: #448888;">i</span> <span style="color: #00b100; font-weight: bold;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">200000</span><span style="color: #66cc66;">&#41;</span> <span style="color: #00b100; font-weight: bold;">do</span> net user TestUser<span style="color: #33cc33;">%</span><span style="color: #448888;">i</span> p<span style="color: #33cc33;">@</span>ssw0rd /domain /add</div></div>
<p>If you need to tweak more of the details of the test accounts, there are a number of other options for the NET USER command, but you most likely will want to take a look at the more robust tools out there like csvde.</p>
<p>Thanks to Daniel Petri for this little nugget.  For a more in depth view of your options for quickly creating test users, check out his post here:</p>
<p><a href="http://www.petri.co.il/create_users_for_testing_purposes.htm" target="_blank">http://www.petri.co.il/create_users_for_testing_purposes.htm</a></p>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/04/07/quickly-create-test-users-on-your-domain-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So I got a fake Intel Core i7-920</title>
		<link>http://code.commongroove.com/2010/03/10/so-i-got-a-fake-intel-core-i7-920/</link>
		<comments>http://code.commongroove.com/2010/03/10/so-i-got-a-fake-intel-core-i7-920/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 00:52:05 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/archive/2010/03/09/so-i-got-a-fake-intel-core-i7-920.aspx</guid>
		<description><![CDATA[Perhaps you have seen the hub-bub about the counterfeit Intel Core i7-920 chips that were sent out across the country between March 1st and March 4th from NewEgg.com (via their distributor)? Well, I got one of these &#8220;chips&#8221; myself!! Here&#8217;s the write-up on the box I received over at GearLog.com from Dan Evans: Hands On: Unboxing the [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps you have seen the hub-bub about the counterfeit Intel Core i7-920 chips that were sent out across the country between March 1st and March 4th from NewEgg.com (via their distributor)? Well, I got one of these &#8220;chips&#8221; myself!!</p>
<p>Here&#8217;s the write-up on the box I received over at <a href="http://www.gearlog.com">GearLog.com</a> from Dan Evans:</p>
<p><a href="http://www.gearlog.com/2010/03/hands_on_fake_intel_core_i7-92_1.php">Hands On: Unboxing the Fake Intel Core i7-920</a></p>
<p>Check it out!</p>
<p>(By the way, NewEgg dealt with this efficiently and quickly offering me either a full refund or another chip via expedited delivery.  Their service rocks! )</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/03/10/so-i-got-a-fake-intel-core-i7-920/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>March 2010 IT Toolbox &#8211; TechNet Magazine Online</title>
		<link>http://code.commongroove.com/2010/03/05/march-2010-it-toolbox-technet-magazine-online/</link>
		<comments>http://code.commongroove.com/2010/03/05/march-2010-it-toolbox-technet-magazine-online/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 23:14:58 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Microsoft TechNet]]></category>

		<guid isPermaLink="false">http://code.commongroove.com/archive/2010/03/05/march-2010-it-toolbox-technet-magazine-online.aspx</guid>
		<description><![CDATA[The March 2010 TechNet Magazine posts on the website. Check out my IT Toolbox column here: March 2010 TechNet Magazine IT Toolbox In this issue I covered: Alloy Navigator Express: Asset, Help Desk, and Inventory Tracking CleanAfterMe: Clean up your tracks KBAlertz.com: Hot fix and security bulletin website Check it out and let me know [...]]]></description>
			<content:encoded><![CDATA[<p>The March 2010 <a title="TechNet Magazine" rel="" target="_blank" href="http://www.technetmagazine.com">TechNet Magazine</a> posts on the website. Check out my IT Toolbox column here:</p>
<p><a target="_blank" href="http://technet.microsoft.com/en-us/magazine/ff458351.aspx">March 2010 TechNet Magazine IT Toolbox</a></p>
<p>In this issue I covered:</p>
<ul>
<li><strong>Alloy Navigator Express</strong>: Asset, Help Desk, and Inventory Tracking</li>
<li><strong>CleanAfterMe</strong>: Clean up your tracks</li>
<li><strong>KBAlertz.com</strong>: Hot fix and security bulletin website</li>
</ul>
<p>Check it out and let me know what you think!</p>
<p>And if you have a tool you want to see me review, please suggest it to me here: <a href="mailto:tntools@microsoft.com">tntools@microsoft.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.commongroove.com/2010/03/05/march-2010-it-toolbox-technet-magazine-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
