<?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>youdidwhatwithtsql.com &#187; random</title>
	<atom:link href="http://www.youdidwhatwithtsql.com/tag/random/feed" rel="self" type="application/rss+xml" />
	<link>http://www.youdidwhatwithtsql.com</link>
	<description>making DBAs everywhere curse!</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Powershell Random sort</title>
		<link>http://www.youdidwhatwithtsql.com/powershell-random-sort/596</link>
		<comments>http://www.youdidwhatwithtsql.com/powershell-random-sort/596#comments</comments>
		<pubDate>Mon, 01 Feb 2010 11:56:00 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Powershell Scripting]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[random sort]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/powershell-random-sort/596</guid>
		<description><![CDATA[Here&#8217;s a Powershell snippet that randomly sorts the lines in a file. The snippet below reads a text file, called file.txt, located in your user profile directory. The data in the file will be written back with the lines in a different order. ?View Code POWERSHELL$data = New-Object System.Object; $data = Get-Content &#34;$Env:USERPROFILE\file.txt&#34;; # Random [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/powershell-random-sort/596">Powershell Random sort</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank">Powershell</a> snippet that randomly sorts the lines in a file. The snippet below reads a text file, called <strong>file.txt</strong>, located in your user profile directory. The data in the file will be written back with the lines in a different order.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p596code3'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5963"><td class="code" id="p596code3"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$data</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Object;
<span style="color: #800080;">$data</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800000;">&quot;$Env:USERPROFILE\file.txt&quot;</span>;
<span style="color: #008000;"># Random sort the lines in the file</span>
<span style="color: #800080;">$data</span> <span style="color: pink;">=</span> <span style="color: #800080;">$data</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#91;</span>System.Guid<span style="color: #000000;">&#93;</span>::NewGuid<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>;
<span style="color: #008080; font-weight: bold;">Set-Content</span> <span style="color: #800000;">&quot;$Env:USERPROFILE\file.txt&quot;</span> <span style="color: #800080;">$data</span>;</pre></td></tr></table></div>

<p>If your file started off like this&#8230;</p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/file_ordered.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="file ordered" border="0" alt="file ordered thumb Powershell Random sort" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/file_ordered_thumb.png" width="244" height="208" /></a> </p>
</p>
<p>It will end up looking something like&#8230;</p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/file_random_sort1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="file random sort" border="0" alt="file random sort thumb Powershell Random sort" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/file_random_sort_thumb.png" width="244" height="234" /></a> </p>
<p>This is functionally equivalent to&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p596code4'); return false;">View Code</a> TSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5964"><td class="code" id="p596code4"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">*</span>
<span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">Customers</span>
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> NEWID<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>;</pre></td></tr></table></div>

<p><map name='google_ad_map_596_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/596?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_596_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=596&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fpowershell-random-sort%2F596' title="Powershell Random sort" alt=" Powershell Random sort" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/powershell-random-sort/596">Powershell Random sort</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/powershell-random-sort/596" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/powershell-random-sort/596/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

