Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to get first 10 records from a table

Author  Topic 

samuel84
Starting Member

1 Post

Posted - 2004-08-25 : 22:05:42
hi experts.,
i would like to select first 5 records from a table where auto number is a primary key, i will give the last record as a input parameter to fetch the next following 5 . how do i achieve this please help me, im doin this to increase the performance while paging.. is ther a sql statement to select first n records from a table
Thanks
Samuel

Sam

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-25 : 22:31:38
Select top n * from Table

Select top 10 * from Table



Corey
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2004-08-25 : 22:33:21
don't forget an ORDER BY clause.



-ec
Go to Top of Page

sagarvt
Starting Member

2 Posts

Posted - 2004-08-26 : 04:45:26
Boss,

If u want only top 5 records then query is like

select top 5 * from <table> order by autono desc;

Suppose if u give autono as 20 and want to get records from 20 to 25 then u need to write a stored procedure for that. confirm this i can give u code for that.

regards
sagar
Go to Top of Page
   

- Advertisement -