Limit the no of rows returned

Posted on 2011-10-20
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

    I am using MS SQL 2005
    LVL 13

    Accepted Solution

    select top 1000 a.testID, b.testNo from ....
    LVL 23

    Assisted Solution

    by:Rajkumar Gs
    Use TOP
    SELECT TOP 1000 * FROM YourTable

    Open in new window

    LVL 13

    Expert Comment

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

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now