Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to Select the Next 20 records in SQL server?

How to Select the Next 20 records in SQL server?

Scheduled Pinned Locked Moved Database
tutorialquestiondatabasesql-serversysadmin
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    star_platinum
    wrote on last edited by
    #1

    Hi All, I know "TOP" Function can select the TOP n records. How can I select records from for example 20 to 50? I know SQL server doesn't have "LIMIT" Function.... Thanks Tin

    W R 2 Replies Last reply
    0
    • S star_platinum

      Hi All, I know "TOP" Function can select the TOP n records. How can I select records from for example 20 to 50? I know SQL server doesn't have "LIMIT" Function.... Thanks Tin

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Have a look at ROW_NUMBER[^]

      The need to optimize rises from a bad design.My articles[^]

      S 1 Reply Last reply
      0
      • W Wendelius

        Have a look at ROW_NUMBER[^]

        The need to optimize rises from a bad design.My articles[^]

        S Offline
        S Offline
        star_platinum
        wrote on last edited by
        #3

        Thanks for your reply, I able to create the row number column but when I tried to select a range of row number. It appeared this error message " Conversion failed when converting the varchar value 'Row_Number' to data type int" I have used cast and convert already. Any idea? Tin

        W 1 Reply Last reply
        0
        • S star_platinum

          Hi All, I know "TOP" Function can select the TOP n records. How can I select records from for example 20 to 50? I know SQL server doesn't have "LIMIT" Function.... Thanks Tin

          R Offline
          R Offline
          Riaan Booyzen
          wrote on last edited by
          #4

          Hi, what you oculd also try is something like this... SELECT top(20)* FROM _yourtable WHERE _tableID not in (select top(20) tableID from _yourtable)

          1 Reply Last reply
          0
          • S star_platinum

            Thanks for your reply, I able to create the row number column but when I tried to select a range of row number. It appeared this error message " Conversion failed when converting the varchar value 'Row_Number' to data type int" I have used cast and convert already. Any idea? Tin

            W Offline
            W Offline
            Wendelius
            wrote on last edited by
            #5

            Could you post the query so it would be easier to see the problem

            The need to optimize rises from a bad design.My articles[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups