Return random rows from a MS SQL database

I always forget this command:

SELECT * FROM YourTable TABLESAMPLE SYSTEM (10 PERCENT)

This gives you some sample data from your database. In this case 10 percent of the content.  You could also use TABLESAMPLE SYSTEM (1000 ROWS) to get 1000 sample rows. Great to use if you have a big database and do not want the same data again and again when you debug or something.

3 Responses to “Return random rows from a MS SQL database”

  1. Incorrect syntax near the keyword ‘Table’.

  2. Oh :) Table is not a keyword. Is wast meant as “myTable” or something!

  3. Table mean the table name in your database. See more in bustajob.com

Leave a Reply