Display 5 records each time from a table sql script

  • Hi Experts

    I want to display 5 records each time from a column until all records are touched in the table.

    Can you suggest a easy script to achieve it.

    Note: if incase in the table the total number of records are less than 5, it will display all records based on the count

    Thanks.

  • How are you going through the table?

    You could use a TOP VALUES query...

    SELECT TOP 5 *

    FROM dbo.MyTable

    WHERE ...

    Where are you sending the records? I guess you could use OFFSET. Read this, maybe.

  • Top 5 will only display top 5 records....but if in the table 1000 rows are there and if I need to display 5 records each time comprising 200 iterations,, do u know a easy method to do that?

    Thanks.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply