tag:blogger.com,1999:blog-25809080.post3426545026836833247..comments2023-07-26T12:26:16.405+03:00Comments on Innovative Perspective: Paging Implementation With SQLMohammed Nourhttp://www.blogger.com/profile/14196471284974987569noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-25809080.post-8837362930798916542007-12-27T13:13:00.000+02:002007-12-27T13:13:00.000+02:00Okay, but how can you retrieve the total number of...Okay, but how can you retrieve the total number of pages in the same query ? Without that you can't decently set up your interface...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25809080.post-852044906076348982007-02-12T17:27:00.000+02:002007-02-12T17:27:00.000+02:00Thanks a lot, this is what i was looking for for S...Thanks a lot, this is what i was looking for for SQL 2005 usage... i made it into a stored proc, that will take a page size and page number passed form C# source.<BR/><BR/><B>CREATE PROC GetSearchResults<BR/>@PageSize INT,<BR/>@PageNumber INT<BR/>AS<BR/>DECLARE @OffSet INT<BR/>SET @OffSet = @PageSize * (@PageNumber - 1)<BR/>SELECT TOP (@PageSize) * FROM [Content] <BR/> WHERE ContentID NOT IN (<BRMusahttps://www.blogger.com/profile/04969831330646197749noreply@blogger.comtag:blogger.com,1999:blog-25809080.post-57433217050042050282007-02-05T19:26:00.000+02:002007-02-05T19:26:00.000+02:00Yeah, that's absolutely correct. However, this dep...Yeah, that's absolutely correct. However, this depends in your application and the way you want to sort your data.Mohammed Nourhttps://www.blogger.com/profile/14196471284974987569noreply@blogger.comtag:blogger.com,1999:blog-25809080.post-64852673079999068002007-02-03T13:18:00.000+02:002007-02-03T13:18:00.000+02:00No, it doesn't depend at all on the ID sequence or...No, it doesn't depend at all on the ID sequence or numbers. If I want to retrieve TOP 10 records, this doesn't mean that IDs should be 1,2,3 ... etc. TOP retrieve only first TOP records of the query result whatever your query depends on ID column or not.Mohammed Nourhttps://www.blogger.com/profile/14196471284974987569noreply@blogger.comtag:blogger.com,1999:blog-25809080.post-61552701756766934742007-02-03T11:53:00.000+02:002007-02-03T11:53:00.000+02:00you would have to make sure all of your id's start...you would have to make sure all of your id's started at 1 and were sequential. not the best approach especially with 'huge data blocks'Rush Frisbyhttps://www.blogger.com/profile/00908078994262746825noreply@blogger.comtag:blogger.com,1999:blog-25809080.post-75083578974090153312007-01-26T16:02:00.000+02:002007-01-26T16:02:00.000+02:00Nice comment! Well.. I was using SQL Server 2000 f...Nice comment! Well.. I was using SQL Server 2000 for this project and ROW_NUMBER is not option here as it wasn't provided yet in this release. I think SQL Server Team consider this paging problem in their 2005 release by providing ROW_NUMER keyword.Mohammed Nourhttps://www.blogger.com/profile/14196471284974987569noreply@blogger.comtag:blogger.com,1999:blog-25809080.post-70307716706281088942007-01-26T15:47:00.000+02:002007-01-26T15:47:00.000+02:00Actually SQL Server 2005 HAS buil in paging suppor...Actually SQL Server 2005 HAS buil in paging support, using the "ROW_NUMBER" keyword.<br />Google for "paging sql server 2005" and you'll find much sample code on that.Mohamed Meligyhttps://www.blogger.com/profile/06133694828261636610noreply@blogger.com