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'
Asked
Active
Viewed 120 times
1

LearnSomethingNew
- 23
- 1
- 5
1 Answers
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