Paging in sql 2000(Query Help)

Hi,

I have to select record on the basis of page number and page size from 
Database.
I am working on SQL server 2000.
In select query sorting and searching included.

Please help me.

Thanks,
Hemant 


0
Hemant
6/16/2010 2:25:29 PM
sqlserver.programming 1873 articles. 0 followers. Follow

1 Replies
791 Views

Similar Articles

[PageSpeed] 2

On Wed, 16 Jun 2010 19:56:05 +0530, "Hemant" <Hemant@nomail.com>
wrote:

>Hi,
>
>I have to select record on the basis of page number and page size from 
>Database.
>I am working on SQL server 2000.
>In select query sorting and searching included.
>
>Please help me.
>
>Thanks,
>Hemant 
>

Okay, you could try this. 

select * from (
	select top page_size * from
	( select top page_no*page_size <your fields>
	<your current from> 
	<your current where>
	<your current order by>
	) as first_x_pages
	order by <your current order by reversed>) as page
 order by <your current order by>

So
select * from (
	select top (20) * from
	( select top (3*20) foo_code, foo_desc
	from foo
	where foo_code like 'A%'
	order by foo_code
	) as first_x_pages
	order by foo_code desc) as page
 order by foo_code


Alternatively, use 

select top XX  etc... 
and include where foo_code > <end_of_last_page from the application>

Iain


Iain
0
Iain
6/16/2010 5:11:37 PM
Reply:

Similar Artilces: