Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Oct 2, 1998

Limiting rows returned by SELECT

Question:
In PL/SQL, the following syntax is allowed:
   SELECT * FROM table WHERE ROWNUM < 25
This would return the first 24 rows of a table.

Is there anything equivalent to this in T-SQL on Microsoft SQL Server 6.5?

Answer:
No. You can limit the number of rows returned with the set ROWCOUNT = N command. But the command does not work the same way as in Oracle. In Oracle, the where rownum < 25 builds the result set, calculates which are the first 25 rows that would be returned, and returns only those rows. SQL Server doesn't guarantee what 25 rows are returned when the set ROWCOUNT is used.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date