Limit the no of rows returned

Posted on 2011-10-20
Medium Priority
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
Question by:newone2011

Author Comment

ID: 37000648
I am using MS SQL 2005
LVL 13

Accepted Solution

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

Assisted Solution

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

Open in new window

LVL 13

Expert Comment

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

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