Que : How To get Random Record every time from a table using a single query ?
create table _record
(
id int identity(1,1),
name varchar(15),
address varchar(15)
)
insert into _record values('naimish','Gondal')
insert into _record values('vimal','Devchadi')
insert into _record values('jugal','junagadh')
insert into _record values('ravi','Amreli')
insert into _record values('Bhadresh','Bhader')
insert into _record values('Mohit','Rajkot')
create table _record
(
id int identity(1,1),
name varchar(15),
address varchar(15)
)
insert into _record values('naimish','Gondal')
insert into _record values('vimal','Devchadi')
insert into _record values('jugal','junagadh')
insert into _record values('ravi','Amreli')
insert into _record values('Bhadresh','Bhader')
insert into _record values('Mohit','Rajkot')
Gives a single random record every time from table
ReplyDeleteyou can see exactly output if hundreds of records in table.
-> select top 1 * from _record order by NEWID()