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


Add to briefcase 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,039, 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: Monday, April 14, 2014 3:07 PM
Points: 2,382, Visits: 3,369
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


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:03 PM
Points: 35,954, Visits: 30,243
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."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #731152
Posted Tuesday, June 09, 2009 12:51 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 8:27 AM
Points: 925, Visits: 1,094
Seems this article is also in random order ?

Wilfred
The best things in life are the simple things
Post #731176
Posted Tuesday, June 09, 2009 1:00 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, April 14, 2014 3:07 PM
Points: 2,382, Visits: 3,369
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, April 09, 2014 9:26 AM
Points: 281, Visits: 181
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, August 22, 2012 7:35 PM
Points: 27, Visits: 62
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
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 1:38 PM
Points: 35, Visits: 279
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
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, May 28, 2013 6:52 AM
Points: 16, Visits: 166
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: Friday, September 17, 2010 4:24 PM
Points: 23, Visits: 172
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 »

Add to briefcase 12345»»»

Permissions Expand / Collapse