greetings of the day
my question is....
how can i select any random data from a table.
i want to pick any row randomly from table.how can i do that.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
TulasiPosted Oct 14, 2011, 7:03 AM
The NEWID() system function makes a unique value of the type uniqueidentifier. There is no need to add a new column in your table to get the random records. you just have to include the NEWID() system function in the ORDER BY clause of your SELECT statement
example for getting FIVE random records
SELECT TOP 5 eid,ename FROM emp
Ex: for one record
SELECT TOP 1 eid,ename FROM emp
Please do not forget to mark "Accpeted Answer".