Tuesday, November 29, 2011

0 TABLESAMPLE

 

We can use the tablesample to limit the return result sets. The difference using tablesample and top is top would always retrieve top N rows but tablesample would get the sampling of the data.

TABLESAMPLE would go to each 8K page and get the sample data. That being said if the table has 20 pages but only one page has all table’s data. It is possible it wont get the data back.

  1. USE AdventureWorks;
  2. SELECT *
  3. FROM person.address
  4. TABLESAMPLE (10 PERCENT)

 

  1. USE AdventureWorks;
  2. SELECT *
  3. FROM person.address
  4. TABLESAMPLE (50 ROWS)

Reference

Limiting Result Sets by Using TABLESAMPLE http://msdn.microsoft.com/en-us/library/ms189108.aspx

0 comments:

Post a Comment

 

SQL Panda Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates