March 20, 2006 at 8:34 am
I use a
SELECT TOP 50 xy FROM MyTable.
Could someone suggest me the better way to get de 50 to 100, 100 to 150 and so on... pages.
Thanks
March 20, 2006 at 9:12 am
Need a where clause and some ordering mechanism.
Like
select top 50 xy from MyTable order by MyID
then for the next 50, send in the last ID you got and query
select top 50 xy from MyTable order by MyID where MyID > @lastid
March 20, 2006 at 9:17 am
So !
this need to get the lastID as :
declare LyID int,
select top 50 xy, @lastID=MyID from MyTable order by MyID
and then
select top 50 xy from MyTable order by MyID where MyID > @lastID
Am I right ?
March 20, 2006 at 9:21 am
But I don't find How to memorize the lastID ???? In my first select request I get the ID, but which is the last ???
March 21, 2006 at 9:37 am
select top 50 xy, @lastID=max(MyID) from MyTable order by MyID
and then
select top 50 xy from MyTable order by MyID where MyID > @lastID
March 21, 2006 at 9:40 am
Sorry, you can't combine the select like that.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply