RSS

How to select rows randomly in SQL Server ??

12 Mar

You can select some of rows or reorder the table depended on a random value. You can do this by the function named NewID().

Try to write this T-SQL script to do this:

SELECT * FROM dbo.Customers ORDER BY NewID()

With this script you can get the table rows in a new randomly result set whenever you run or execute this.

 
Leave a comment

Posted by on March 12, 2012 in MS SQL Server

 

Tags: , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: