Hi,I have a query that runs, with built in paging via temp tables as shown in the query below. I'm not sure if I'm correct in thinking this, but I'm thinking that for the queries in which "@page=1" is passed, we could have a different query that is basically just a SELECT TOP statement, so we don't go thru the temp table process etc. I've never seen this written into a temp table paging solution, I'm wondering if theres a reason for this ?I guess testing is the only real way to determine. I'm workin a lil rusty and trying to figure out the best way to do it here still. Any help and input much appreciated !! Thanks very much!!mike123CREATE PROCEDURE [dbo].[select_mailbox_paging] ( @userID int, @page int, @recsPerPage tinyint)AS SET NOCOUNT ON-- We don't want to return the # of rows inserted-- into our temporary table, so turn NOCOUNT ONSET NOCOUNT ON--Create a temporary tableCREATE TABLE #TempMail( ID int IDENTITY, messageid int, messagefrom int, subject varchar(100), date datetime, nameOnline varchar(50), checked tinyint,)-- Insert the rows from tblItems into the temp. tableINSERT INTO #TempMail (messageid, messagefrom, subject, date, nameOnline, checked)SELECT messageid, messagefrom, subject, M.date, nameonline, checked FROM tblMessage MJOIN tbluserdetails UD ON M.messagefrom = UD.userid WHERE messageTo=@userID AND deletedByRecipient = 0 ORDER BY M.date DESC-- Find out the first and last record we wantDECLARE @FirstRec int, @LastRec intSELECT @FirstRec = (@Page - 1) * @RecsPerPageSELECT @LastRec = (@Page * @RecsPerPage + 1)-- Now, return the set of paged records, plus, an indiciation of we-- have more records or not!SELECT *, MoreRecords = ( SELECT COUNT(messageid) FROM #TempMail TM WHERE TM.ID >= @LastRec ) FROM #TempMailWHERE ID > @FirstRec AND ID < @LastRec-- Turn NOCOUNT back OFFSET NOCOUNT OFF