SQLTeam.com | Weblogs | Forums

Top 20 versus row number between 1 and 20

Hi, two SQL queries to fetch 20 records from a table were written using top and rownumber(). Found in SQL profiler that query using top 20 was reading more records and also performing some write operation. Where as rownumber is reading less records. What is the difference between their usage and performance?

That depends on the specifics of the query. For example, ROWNUMBER() requires an ORDER BY whereas TOP does not.