<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Generate A Single Random Number for Range of Rows of Any Table &#8211; Very interesting Question from Reader</title>
	<atom:link href="http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 23 May 2013 14:22:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Generate Random Values &#8211; SQL in Sixty Seconds #042 &#8211; Video &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-418364</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Generate Random Values &#8211; SQL in Sixty Seconds #042 &#8211; Video &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 06 Feb 2013 01:30:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-418364</guid>
		<description><![CDATA[[...] Generate A Single Random Number for Range of Rows of Any Table – Very interesting Question from Re... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Generate A Single Random Number for Range of Rows of Any Table – Very interesting Question from Re&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #014 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-417357</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #014 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sun, 03 Feb 2013 22:56:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-417357</guid>
		<description><![CDATA[[...] Generate A Single Random Number for Range of Rows of Any Table – Very interesting Question from Re... Generating random number has been always fun to me. Though the word says random, nothing is truly random if you look at it. To generate the random number has had to use logic and make sure that the number is really random and not predictable. In this blog post, I go over a couple of methods of how to generate random numbers. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Generate A Single Random Number for Range of Rows of Any Table – Very interesting Question from Re&#8230; Generating random number has been always fun to me. Though the word says random, nothing is truly random if you look at it. To generate the random number has had to use logic and make sure that the number is really random and not predictable. In this blog post, I go over a couple of methods of how to generate random numbers. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Retrieving Random Rows from Table Using NEWID() &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-374657</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Retrieving Random Rows from Table Using NEWID() &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Fri, 16 Nov 2012 01:31:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-374657</guid>
		<description><![CDATA[[...] SQL SERVER – Generate A Single Random Number for Range of Rows of Any Table – Very interesting Q... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER – Generate A Single Random Number for Range of Rows of Any Table – Very interesting Q&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: akhtar</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-277195</link>
		<dc:creator><![CDATA[akhtar]]></dc:creator>
		<pubDate>Wed, 18 Apr 2012 07:17:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-277195</guid>
		<description><![CDATA[HELP ME OUT FOR A SQL 2005 QUERY TO FIND ROW NO THE RECORD
VIZ . RAJESH EXSIST ON ROW NO 5]]></description>
		<content:encoded><![CDATA[<p>HELP ME OUT FOR A SQL 2005 QUERY TO FIND ROW NO THE RECORD<br />
VIZ . RAJESH EXSIST ON ROW NO 5</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: suresh</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-268976</link>
		<dc:creator><![CDATA[suresh]]></dc:creator>
		<pubDate>Wed, 28 Mar 2012 13:54:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-268976</guid>
		<description><![CDATA[how to random record from database(Sql Server) table each time when i am executing the Query, i want to use it to Quiz application]]></description>
		<content:encoded><![CDATA[<p>how to random record from database(Sql Server) table each time when i am executing the Query, i want to use it to Quiz application</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ariel</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-226197</link>
		<dc:creator><![CDATA[Ariel]]></dc:creator>
		<pubDate>Mon, 26 Dec 2011 14:32:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-226197</guid>
		<description><![CDATA[Solved it like this (using one of your random creation scripts from above):

declare @cursor cursor, @userID int
set     @cursor = cursor for 
	(select id
	 from users)
open @cursor

while 1=1
 begin
    fetch from @cursor into @userID;
    if @@fetch_status  0
        break
     
	update users set reportMonthDay = 1 + CONVERT(INT, 28*RAND()) 
	where id=@userID
  	
 end]]></description>
		<content:encoded><![CDATA[<p>Solved it like this (using one of your random creation scripts from above):</p>
<p>declare @cursor cursor, @userID int<br />
set     @cursor = cursor for<br />
	(select id<br />
	 from users)<br />
open @cursor</p>
<p>while 1=1<br />
 begin<br />
    fetch from @cursor into @userID;<br />
    if @@fetch_status  0<br />
        break</p>
<p>	update users set reportMonthDay = 1 + CONVERT(INT, 28*RAND())<br />
	where id=@userID</p>
<p> end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ariel</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-226194</link>
		<dc:creator><![CDATA[Ariel]]></dc:creator>
		<pubDate>Mon, 26 Dec 2011 14:22:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-226194</guid>
		<description><![CDATA[While trying to find an answer for the Scenario: Single Random Number for Set of Rows (Using RAND()), my use of this would be to ~~equally cut a table into groups, for example: cut 20000 records into 7 days or 28 days. So each row will get a random number between 1,7 so you have 7 groups.]]></description>
		<content:encoded><![CDATA[<p>While trying to find an answer for the Scenario: Single Random Number for Set of Rows (Using RAND()), my use of this would be to ~~equally cut a table into groups, for example: cut 20000 records into 7 days or 28 days. So each row will get a random number between 1,7 so you have 7 groups.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EstebanD</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-60049</link>
		<dc:creator><![CDATA[EstebanD]]></dc:creator>
		<pubDate>Thu, 21 Jan 2010 16:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-60049</guid>
		<description><![CDATA[@Samson Loo

Great Tip! thanks!]]></description>
		<content:encoded><![CDATA[<p>@Samson Loo</p>
<p>Great Tip! thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samson Loo</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-46576</link>
		<dc:creator><![CDATA[Samson Loo]]></dc:creator>
		<pubDate>Wed, 11 Feb 2009 16:53:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-46576</guid>
		<description><![CDATA[Let&#039;s say I want to check random records from my dataset and I want exactly 100 records returned.  Well I would run the following: SELECT TOP 100 FROM TABLE_NAME ORDER BY NEWID()


I dont want just the first top 100, I want 100 random records and I am not trying to generate a new GUID.  Which is why I use it in the ORDER BY clause.  It works good for my purposes!]]></description>
		<content:encoded><![CDATA[<p>Let&#8217;s say I want to check random records from my dataset and I want exactly 100 records returned.  Well I would run the following: SELECT TOP 100 FROM TABLE_NAME ORDER BY NEWID()</p>
<p>I dont want just the first top 100, I want 100 random records and I am not trying to generate a new GUID.  Which is why I use it in the ORDER BY clause.  It works good for my purposes!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mehdi</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-46372</link>
		<dc:creator><![CDATA[Mehdi]]></dc:creator>
		<pubDate>Thu, 05 Feb 2009 16:15:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-46372</guid>
		<description><![CDATA[I like to generate a random number for primary key, so I can get one of the ads randomly to come up for a page.
I think this would be a real life scenario where its needed.]]></description>
		<content:encoded><![CDATA[<p>I like to generate a random number for primary key, so I can get one of the ads randomly to come up for a page.<br />
I think this would be a real life scenario where its needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Beukes</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-46134</link>
		<dc:creator><![CDATA[Johan Beukes]]></dc:creator>
		<pubDate>Thu, 29 Jan 2009 11:53:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-46134</guid>
		<description><![CDATA[One way of looking at the request is:

Say there are 5 records with PostalCode=98011. The reader may want to retrieve any one of these 5 records when running a query. Next time the query is run, he may want to retrieve another random record with same PostalCode

?]]></description>
		<content:encoded><![CDATA[<p>One way of looking at the request is:</p>
<p>Say there are 5 records with PostalCode=98011. The reader may want to retrieve any one of these 5 records when running a query. Next time the query is run, he may want to retrieve another random record with same PostalCode</p>
<p>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajib Bahar</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-46108</link>
		<dc:creator><![CDATA[Rajib Bahar]]></dc:creator>
		<pubDate>Wed, 28 Jan 2009 22:33:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-46108</guid>
		<description><![CDATA[I will guess it depends on what he&#039;s doing. :)

It maybe, he&#039;s exploiting the random number for session management or presenting the result in some format in front-end/reports or working with some existing or new design pattern that requires it.]]></description>
		<content:encoded><![CDATA[<p>I will guess it depends on what he&#8217;s doing. :)</p>
<p>It maybe, he&#8217;s exploiting the random number for session management or presenting the result in some format in front-end/reports or working with some existing or new design pattern that requires it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan G. Switzer, II</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-46070</link>
		<dc:creator><![CDATA[Dan G. Switzer, II]]></dc:creator>
		<pubDate>Wed, 28 Jan 2009 14:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-46070</guid>
		<description><![CDATA[The way that the RAND() funciton works, as long as the unique value you want a distinct random number for is an integer, you can do something like:

select 
	rand(PostalCode) as RandomNumber, PostalCode
from 
	Person.Address
where
	StateProvinceID = 79
order by
 PostalCode

The RAND() function will only return one unique value for each seed, so if you pass it a common seed all of those rows would share the same random value.]]></description>
		<content:encoded><![CDATA[<p>The way that the RAND() funciton works, as long as the unique value you want a distinct random number for is an integer, you can do something like:</p>
<p>select<br />
	rand(PostalCode) as RandomNumber, PostalCode<br />
from<br />
	Person.Address<br />
where<br />
	StateProvinceID = 79<br />
order by<br />
 PostalCode</p>
<p>The RAND() function will only return one unique value for each seed, so if you pass it a common seed all of those rows would share the same random value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samson Loo</title>
		<link>http://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/#comment-46069</link>
		<dc:creator><![CDATA[Samson Loo]]></dc:creator>
		<pubDate>Wed, 28 Jan 2009 14:12:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2140#comment-46069</guid>
		<description><![CDATA[I use it a lot.  Mainly for checking the integrity of my data mapping before it hits production on my deployments.]]></description>
		<content:encoded><![CDATA[<p>I use it a lot.  Mainly for checking the integrity of my data mapping before it hits production on my deployments.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
