-2

I wonder, is there any option like "Skip"(from LINQ) in SQL to select particular rows in a table.

I mean, in a table named "abcd". In that table 300 rows are there. but from that 300 rows i want to select rows from 233 to 300 or 233 to 258.

How to do this?? Please anyone help.

nasr18
  • 75
  • 1
  • 3
  • 13
  • When you use the `Skip` operator in LINQ-to-SQL, it actually generates SQL code to execute it server-side. You can verify this yourself with something like `Console.WriteLine(myContext.Entities.Skip(50).Take(10))`, and you'll see the auto-generated SQL code for skipping rows. – mellamokb Jun 10 '15 at 18:58

1 Answers1

0

You can use a cte or derived table for this:

With cte as (
    Select col1, col2, row_number() over(order by sortColumn) as rn
    From table
)
Select * 
from cte 
Where rn >= 233
And rn <= 258
Zohar Peled
  • 79,642
  • 10
  • 69
  • 121