You must Sign In to post a response.
  • Category: SQL Server

    Limit concept is in SQL SERVER

    Is Limit concept in SQL SERVER? What is the use of this concept?
  • #752467
    Hi,

    There is a limit cluase in mysql server , you can set limitation to a row if you set limit 20 to a query than that takes only 20 records from table like this

    select * from tableName limit 20

    It will take only 20 rows from table.

    In ms sql server you can use top cluase instead of limit
    You cannot use limit in ms sql , if you set top 20 to query than you get 20 records from table like this.

    select top 20 from tableName order by id asc

    I hope you got my point,if still you have an issue than i'll get back to you.

    Regards,
    Nirav Prabtani (Senior Web Developer)
    Email : niravjprabtani@gmail.com
    blog : niravprabtani.blogspot.in

  • #752468
    LIMIT is not sql server Clause it is the MySQL clause, Limit clause used to fetch limited number of records.
    Oracle uses ROWNUM to fetch limited number of records
    And SQL uses TOP clause to fetch limited number of records
    here is the syntax

    SELECT TOP number|percent column_name(s)
    FROM table_name
    WHERE [condition]

    //in SQL
    SELECT TOP 3 * FROM emp

    //in MySQL
    SELECT * FROM emp
    LIMIT 3;

    //in Oracle
    SELECT * FROM emp
    WHERE ROWNUM <= 3;

    hope it helps

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #752489
    [Response removed by Admin. Read forum policies.]

  • #752546
    Hi Dinesh,

    When ever you want to limit the number of rows of a result of a query in PLSQL, you can use LIMIT function of mysql. This work as follows-
    Syntax:

    [SQL Statement ]
    LIMIT [N];

    Where N is the number of records that you want to retrieve from the sql query result.
    The below example can explain it in better way-

    SELECT col1, col2, col3
    FROM tblname
    ORDER BY col1 DESC
    LIMIT 2;

    Hope this will help you !!

    Thanks,
    Ashutosh Jha
    http://tricksroad.com


  • Sign In to post your comments