Skip navigation

How can I restrict the number of rows returned to my query in SQL Server?

A. With SQL 6.5 and below use the "set rowcount <n>" option.

This option is still available with SQL 7.0, but this supports the TOP() function as well which will optimise better so use this instead. "select TOP(n) from .........."

TAGS: SQL Server
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.