/ Published in: SQL
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"
"The expression CAST(CHECKSUM(NEWID(), SalesOrderID) & 0x7fffffff AS float / CAST (0x7fffffff AS int) evaluates to a random float value between 0 and 1"
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
SELECT * FROM Sales.SalesOrderDetail WHERE 0.01 >= CAST(CHECKSUM(NEWID(), SalesOrderID) & 0x7fffffff AS FLOAT) / CAST (0x7fffffff AS INT)
URL: http://msdn.microsoft.com/en-us/library/ms189108.aspx