how to use Limit in Sql server

Discussion in 'SQL Server' started by prabhat1, Apr 9, 2008.

  1. prabhat1

    prabhat1 New Member

    Joined:
    Mar 21, 2008
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    hiiiiiiii.......... i want to use limit in my query to show only few items from database.

    For example i have ..10 values in my table but at a time i want to retrieve only 5 at a time

    The LIMIT works well in My SQL but not in SQL server

    please gve me the sample query.......

    thanks in advance..........

    prabhat..........
     
  2. sql-programs

    sql-programs New Member

    Joined:
    Oct 21, 2009
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Software Developer
    Home Page:
    http://www.sql-programmers.com
    Sql Server does not have a LIMIT functionality. You can use TOP.

    Code:
    select TOP 5 * from Table1
     
  3. urstop

    urstop New Member

    Joined:
    Oct 17, 2007
    Messages:
    84
    Likes Received:
    0
    Trophy Points:
    0
    You can use TOP to get the required number of records from the starting position in the result set, but there is no direct way to get records from a specific position as we have with LIMIT.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice