SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


12345»»»

Random problems Expand / Collapse
Author
Message
Posted Monday, June 08, 2009 9:52 PM
SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, May 18, 2007 3:36 PM
Points: 10,040, Visits: 1
Comments posted to this topic are about the item Random problems
Post #731102
Posted Monday, June 08, 2009 11:57 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, March 12, 2010 12:23 PM
Points: 2,146, Visits: 2,507
One of five orders?

Wouldn't a simple

SELECT TOP 20 PERCENT OrderID
FROM Table1
ORDER BY NEWID()

do?



N 56°04'39.16"
E 12°55'05.25"
Post #731149
Posted Tuesday, June 09, 2009 12:06 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:35 PM
Points: 20,151, Visits: 13,688
Steve... I'm not sure what's happened, but this article is all but unreadable. Might look fine from Firefox, but IE8 is having a heck of a time with it.

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #731152
Posted Tuesday, June 09, 2009 12:51 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Today @ 4:15 PM
Points: 746, Visits: 840
Seems this article is also in random order ?


Post #731176
Posted Tuesday, June 09, 2009 1:00 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, March 12, 2010 12:23 PM
Points: 2,146, Visits: 2,507
And it's also well established that

ABS(CHECKSUM(NEWID())) % 100

gives random numbers between 0 and 99 with very high, good and even distribution.



N 56°04'39.16"
E 12°55'05.25"
Post #731187
Posted Tuesday, June 09, 2009 3:11 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, January 20, 2010 2:58 AM
Points: 269, Visits: 151
You have a run-away <pre> block in there after the first result set which is breaking the formatting. (and I didn't expect to have to html encode <)
Post #731250
Posted Tuesday, June 09, 2009 6:54 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, July 08, 2009 1:48 AM
Points: 27, Visits: 54
Not sure if number of rows matter if this was just for audit purpose I suppose you would not be strict on number of rows.

select * from invoice tablesample (10 percent)

This might work as well.
Post #731400
Posted Tuesday, June 09, 2009 7:13 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, March 10, 2010 11:02 AM
Points: 22, Visits: 70
NewID() create a unique ID, but with CHECKSUM it seems cannot guarantee to be unique again.
Post #731412
Posted Tuesday, June 09, 2009 7:23 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: 2 days ago @ 10:58 AM
Points: 8, Visits: 86
I'm with Peso on this one.
Post #731426
Posted Tuesday, June 09, 2009 7:37 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 6:45 AM
Points: 22, Visits: 152
The XLeratorDB function library inlcudes a RANDBETWEEN scalar function which works just like the EXCEL RANDBETWEEN function. You could have just included RANDBETWEEN(1, 5) in your select and you would have gotten the results you wanted. You can find out more about this function at http://www.westclintech.com/Documentation/XLeratorDBmathDocumentation/tabid/140/topic/RANDBETWEEN/Default.aspx
Post #731434
« Prev Topic | Next Topic »

12345»»»

Permissions Expand / Collapse