Reputation: 124
How to select a particular set of records depending on Primary Key. Suppose my Primary Key is integer which are not sequential. If I specify 1023(which exists in table) then I should get the next specified number(suppose 50) records.
Can this be possible to do it?
Any Ideas?
Upvotes: 0
Views: 86
Reputation: 1
It depends on how you want to calculate the result set. For the simple example where you want to find the result + 50, you can do something like this:
select primaryKey+50
from [TableName]
where primaryKey=1023
If I've misunderstood your question, please let me know
Upvotes: 0
Reputation: 2706
Select * from [Table Name]
where primaryKey >= 1023
and primaryKey < (1023 + 50)
Upvotes: 1
Reputation: 171411
select top 50 *
from MyTable
where MyKey > 1023
order by MyKey
Upvotes: 3