Simon's SQL

SQL,DBA,tuning,Trouble Shooting,Performance

Archive for June 12th, 2014

Selecting Rows Randomly from a Large Table

Posted by Simon Cho on 06/12/2014

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

SELECT * FROM Table1
WHERE (ABS(CAST(
(BINARY_CHECKSUM(*) *
RAND()) as int)) % 100) < 10 — Percent

SELECT * FROM Table1 TABLESAMPLE (1 percent) ORDER BY NEWID()

Posted in Common | Tagged: , , | Leave a Comment »