tag:blogger.com,1999:blog-6799088.post114252308224679554..comments2024-03-28T07:20:33.424+00:00Comments on Instant Badger: Tip of the day : Selecting Random RowsAlistair Davidsonhttp://www.blogger.com/profile/07415960315873865766noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6799088.post-25524220106063914082011-03-18T10:49:21.922+00:002011-03-18T10:49:21.922+00:00Bala
Are you on SQL Server? If so, then as the ar...Bala<br /><br />Are you on SQL Server? If so, then as the article says, the random number generator only gets seeded at the start of execution <br /><br />AlAlistair Davidsonhttps://www.blogger.com/profile/07415960315873865766noreply@blogger.comtag:blogger.com,1999:blog-6799088.post-60083690635045790692011-03-18T10:44:28.636+00:002011-03-18T10:44:28.636+00:00I tried this query
select top 5 RAND() as Random...I tried this query <br /><br />select top 5 RAND() as RandomNumber,Title from HumanResources.Employee<br />order by 1<br /><br />but unfortunately i get the same random numbers and the resultset doesn't seem to be changedBalahttps://www.blogger.com/profile/09467516581134039651noreply@blogger.comtag:blogger.com,1999:blog-6799088.post-85246138214180981662008-08-04T14:24:00.000+01:002008-08-04T14:24:00.000+01:00Visit Select Random Records for More Details.Visit <A HREF="http://technoexperts.blogspot.com/2008/08/random-records-from-sqlserver-database.html" REL="nofollow">Select Random Records</A> for More Details.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6799088.post-73064185674743000562008-08-04T14:23:00.000+01:002008-08-04T14:23:00.000+01:00Visit http://technoexperts.blogspot.com/2008/08/ra...Visit http://technoexperts.blogspot.com/2008/08/random-records-from-sqlserver-database.html for More Details.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6799088.post-61905316233879499432007-04-23T16:55:00.000+01:002007-04-23T16:55:00.000+01:00Nice trick. Thanks.Nice trick. Thanks.Amboy Observerhttps://www.blogger.com/profile/02364240920939457248noreply@blogger.comtag:blogger.com,1999:blog-6799088.post-1150986922887261632006-06-22T15:35:00.000+01:002006-06-22T15:35:00.000+01:00Works great. Thanks!Works great. Thanks!Kristofer Krausehttps://www.blogger.com/profile/00715084587222905919noreply@blogger.comtag:blogger.com,1999:blog-6799088.post-1142549977289421982006-03-16T22:59:00.000+00:002006-03-16T22:59:00.000+00:00You could actually just do ORDER BY newid() in the...You could actually just do ORDER BY newid() in the t-sql example without actually selecting the newid(), small difference I suppose but it looks cleaner to me. There are some drawbacks to the technique which the commenters on my similar post mention at http://www.remotesynthesis.com/blog/index.cfm/2006/1/30/Random-Records-in-TSQLAnonymousnoreply@blogger.com