Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Randomize Select of User IDs? 1

Status
Not open for further replies.

EchoAlertcom

IS-IT--Management
Oct 8, 2002
239
0
0
US
Hello,

I have a user who is asking if I can randomly select 100 records from a table based off of UID which is the primary key of that table.

Select UID, Username from dbo.customers

would be a query i would use to select all from that table.

I know i use Top 100 to limit to 100, but how do i make it so each time the query is run that it randomly selects a 100 potentially different records each time?

Warmest Regards,
Steve
 
Code:
Select Top 100 UID, Username 
from   dbo.customers 
[!]Order By NewId()[/!]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top