sql select only specfic number of rows

Posted on 2009-04-29
Last Modified: 2012-05-06

How can we restrict to select maximum of 100 rows in SQL.
Some times, i will have having 100000 records in d/b but i need to fetch only  maximum of 100 rows please let me know how I can achieve this in SQL. Once i get 100 roes i want to bind it to grid.
Question by:ram27
    LVL 6

    Expert Comment

    Add the SAMPLE 100 to the end

    LVL 15

    Accepted Solution

    I like to use the "SELECT top(100) * FROM..." method.  Note, you can change the 100 to any integer value and NO comma is needed before the * (ie. no comma between the "(100)" and the "*").
    LVL 39

    Assisted Solution

    To add on to the correct answer that sl8rz has already provided

    "you can change the 100 to any integer value"

    It can also be an INT variable.  so if you are passing the value into a procedure.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    745 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

    14 Experts available now in Live!

    Get 1:1 Help Now