?
Solved

Limit the no of rows returned

Posted on 2011-10-20
4
Medium Priority
?
157 Views
Last Modified: 2012-05-12
I have a query which returns 10,000+ rows. How can I limit to see only top 1000
for example
select a.testID, b.testNo from,.....

....order by a.testID
0
Comment
Question by:newone2011
4 Comments
 

Author Comment

by:newone2011
ID: 37000648
I am using MS SQL 2005
0
 
LVL 13

Accepted Solution

by:
Jesus Rodriguez earned 1000 total points
ID: 37000690
select top 1000 a.testID, b.testNo from ....
0
 
LVL 23

Assisted Solution

by:Rajkumar Gs
Rajkumar Gs earned 1000 total points
ID: 37000694
Use TOP
SELECT TOP 1000 * FROM YourTable

Open in new window

0
 
LVL 13

Expert Comment

by:dwkor
ID: 37001033
Use TOP and don't forget to specify Order By. Otherwise the sorting order would depend on the execution plan
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question