<?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>SkeyMedia &#187; Rand Function</title>
	<atom:link href="http://skeymedia.com/tag/rand-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://skeymedia.com</link>
	<description>Blogging about Web Development and Website Management &#38; Monetization</description>
	<lastBuildDate>Sun, 20 Sep 2009 23:18:52 +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>Rand() isn&#8217;t Random</title>
		<link>http://skeymedia.com/rand-isn-t-random/</link>
		<comments>http://skeymedia.com/rand-isn-t-random/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 21:00:18 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rand Function]]></category>
		<category><![CDATA[SQL2000]]></category>

		<guid isPermaLink="false">http://skeymedia.com/rand-isn-t-random/</guid>
		<description><![CDATA[If you use Microsoft SQL 2000, you&#8217;ve probably at one point had to pull random results. The built in rand() function simply doesn&#8217;t work. It gives you a random value the first time, and every time after it is the same it seems. I found a new way to do this today after 20 pages [...]]]></description>
			<content:encoded><![CDATA[<p>If you use Microsoft SQL 2000, you&#8217;ve probably at one point had to pull random results.  The built in rand() function simply doesn&#8217;t work.  It gives you a random value the first time, and every time after it is the same it seems.</p>
<p>I found a new way to do this today after 20 pages of searching, so hopefully this will help someone else.</p>
<p><code>ORDER BY newid()</code></p>
<p>yup, it&#8217;s that simple.</p>
<p><pre><code>
SELECT
&nbsp;&nbsp;TOP 2 
&nbsp;&nbsp;&nbsp;&nbsp;field1
&nbsp;&nbsp; ,field2
FROM
&nbsp;&nbsp;TABLE
WHERE
&nbsp;&nbsp;field1 = 1
ORDER BY
&nbsp;&nbsp;newid()
</code></pre></p>
<p>To be noted, this will put a full table scan in place before it selects the top 2, so keep performance in mind.</p>
]]></content:encoded>
			<wfw:commentRss>http://skeymedia.com/rand-isn-t-random/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
