Posted By

michanne on 05/10/11


Tagged

sqlserver


Versions (?)

Sample Table Sample


 / Published in: SQL
 

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

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"

  1. SELECT * FROM Sales.SalesOrderDetail
  2.  
  3. WHERE 0.01 >= CAST(CHECKSUM(NEWID(), SalesOrderID) & 0x7fffffff AS float)
  4.  
  5. / CAST (0x7fffffff AS int)

Report this snippet  

You need to login to post a comment.