Return to Snippet

Revision: 45868
at May 10, 2011 04:18 by michanne


Initial Code
SELECT * FROM Sales.SalesOrderDetail 

WHERE 0.01 >= CAST(CHECKSUM(NEWID(), SalesOrderID) & 0x7fffffff AS float) 

/ CAST (0x7fffffff AS int)

Initial URL
http://msdn.microsoft.com/en-us/library/ms189108.aspx

Initial Description
Alternate to tablesample clause. Example from BOL

"The expression CAST(CHECKSUM(NEWID(), SalesOrderID) & 0x7fffffff AS float / CAST (0x7fffffff AS int) evaluates to a random float value between 0 and 1"

Initial Title
Sample Table Sample

Initial Tags


Initial Language
SQL