How To Use Limit Keyword In Sql Server 2005?
I have found a way to select random rows from a table in this post. A suggestion is to use the following query: SELECT * FROM employee ORDER BY RAND() LIMIT 1 But when I run this
Solution 1:
If you take a look at the SELECT statement in SQL Server Books Online, then you'll see that you can limit the resultset by using the TOP keyword.
SELECT TOP1 * FROM employee
Solution 2:
SELECT TOP1 * FROM Employee ORDER BY newid()
You have to use newid() for it to be evaluated once per row.
Post a Comment for "How To Use Limit Keyword In Sql Server 2005?"