1

In SQL, how are you going to select 1 of the 5 random name every time the query executes? for example, given that the names are 'Joey', 'John', 'Jay', 'George', 'Greg'

1 Answers1

4

The traditional way to get a random row from a table in SQL Server is:

select top 1 name
from names
order by newid();
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786