Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get particular row using SPROC 1

Status
Not open for further replies.

whatsthehampton

Programmer
Sep 13, 2005
121
CA
HI,

I have a grid with paging - when the grid is paged I want to get the top row for each page - so for example if the paging is set at 10 records I need to get the 11th record, 21st record and so on.

How can I do this with a stored procedure please?

Cheers,

J

 
Many thanks markros,

That led me to this Sproc which will work in SQL Server 2005 and did the trick nicely.

SELECT * FROM
(SELECT Row_Number() OVER (ORDER BY jobid desc) as rowid,
jobid, jobdesc, jobtitle
FROM tbl_jobs )
as a
where rowid = @rowid

Now, whatever the paging size is I can calculate and get the specific row I need. i.e.

@rowid = (PageSize * PageNumber) + 1

Cheers,

J

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top