Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How do you limit the number of results in Select?

Author  Topic 

Prestidigitator
Starting Member

16 Posts

Posted - 2007-05-29 : 13:46:37
In other SQL programs I have seen the use of Limit to tell it how many rows to return.

Is there an equivalent in MS-SQL that will let me do a quick Select clause and tell it how many rows to return.

In other words if I just wanted to see the first 10 rows what would I add to
Select * from tableA


Thanks!

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-29 : 13:48:19
Select top 10 * from tableA

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2007-05-29 : 14:46:40
Or

SET ROWCOUNT 10

Select * from tableA

SET ROWCOUNT 0 --Reset back to ALL

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page
   

- Advertisement -