Skip navigation

Learn To Restrict the Number of Rows Returned To the Query In SQL Server

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

e.g. SET ROWCOUNT 10 
SELECT * FROM <tbl>

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. Note that the database concerned MUST be in SQL 7.0 compatibility mode - run sp_dbcmptlevel <dbname> to check whether it is or not.

e.g. select TOP(10) from <tbl> 


TAGS: SQL
Hide comments

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.
Publish