|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What's wrong in my Select StatmentI'm try to run this procedure to implement Custom paging so i pass 2
paramters @PageIndex, @PageSize so if i @PageSize = 5 and PageIndex =2 (0 based index) then i want to ignore first 10 Rows right?? I wrote the following select statment: SELECT TOP 5 * FROM EVENTS WHERE NOT EXISTS ( SELECT TOP 10 * FROM EVENTS T WHERE T.ID = EVENTS.ID ) I expected it will return 5 rows but it return null!! What's wrong?? Use SET ROWCOUNT n.
http://msdn2.microsoft.com/en-us/library/ms188774.aspx Don't forget to set rowcount back to 0 at the end of your query. ML --- http://milambda.blogspot.com/ I think you'd be wanting something like:
SELECT TOP 5 * FROM EVENTS as AlwaysUseAsForAliases WHERE AlwaysUseAsForAliases.ID NOT IN ( SELECT TOP 10 T.ID FROM EVENTS T ) Hi Islamegy,
Here's an article on paging which you might find helpful... http://weblogs.sqlteam.com/jeffs/archive/2003/12/22/672.aspx Show quote "Islamegy®" wrote: > I'm try to run this procedure to implement Custom paging so i pass 2 > paramters @PageIndex, @PageSize > so if i @PageSize = 5 and PageIndex =2 (0 based index) > > then i want to ignore first 10 Rows right?? > I wrote the following select statment: > > SELECT TOP 5 * FROM EVENTS WHERE NOT EXISTS > ( > SELECT TOP 10 * FROM EVENTS T WHERE T.ID = EVENTS.ID > ) > > I expected it will return 5 rows but it return null!! > What's wrong?? > > > |
|||||||||||||||||||||||