Introduction:
Sometimes it is required to show data from specific range
of rows in our application from database. Suppose Record No 10-20. We can
achieve this by simple SQL query.
I will explain how to get/retrieve specific range of rows from SQL Server database table? Suppose there are 100 rows in your table and you want to retrieve only specified rows e.g. 10th to 20th. You can do this by using ROW_NUMBER () function provided by SQL server.
I will explain how to get/retrieve specific range of rows from SQL Server database table? Suppose there are 100 rows in your table and you want to retrieve only specified rows e.g. 10th to 20th. You can do this by using ROW_NUMBER () function provided by SQL server.
SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (ORDER BY EmpId) AS row FROM MyTable) temp
This query will
retrieve the records from rows 10 to 20 from your table.
0 comments:
Post a Comment