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 2005 Forums
 Transact-SQL (2005)
 Pagination HELP!!!!

Author  Topic 

tkotey
Yak Posting Veteran

75 Posts

Posted - 2008-09-24 : 01:57:32
Hi Guys,

I am trying to achieve pagination in my web app but I can't seem to get it right. I have searched high and low on the net for a solution but it has been fruitless so far. I would like to use ROW_NUMBER() function.

SELECT DISTINCT TOP $limit tblInvoice.*, tblTrackingHQ.*, tblUsers.uTown FROM  tblInvoice INNER JOIN  tblTrackingHQ ON tblInvoice.invTrackNo = tblTrackingHQ.invTrackNo CROSS JOIN tblUsers (SELECT ROW_NUMBER() OVER (ORDER BY invTrackNo) AS row, * FROM tblInvoice) where tblUsers.uTown= '".$name."' AND tblTrackingHQ.invStatus <> 7 ORDER BY tblInvoice.invTrackNo


Could some please help me write a proper SQL statement to use for paging with ROW_NUMBER()

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-24 : 02:07:20
one paging procedure can be found here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111099
Go to Top of Page

tkotey
Yak Posting Veteran

75 Posts

Posted - 2008-09-24 : 02:18:07
quote:
Originally posted by visakh16

one paging procedure can be found here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111099


I am trying to avoid stored procedures for now because I am not very good with them and my app is written in PHP. Is there just an SQL statment I could use.

If you look at my SQL statement above, what would you change to make it work?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-24 : 02:24:00
quote:
Originally posted by tkotey

quote:
Originally posted by visakh16

one paging procedure can be found here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111099


I am trying to avoid stored procedures for now because I am not very good with them and my app is written in PHP. Is there just an SQL statment I could use.

If you look at my SQL statement above, what would you change to make it work?


then use the statement within stored procedure itself just replace parameters with your variables
Go to Top of Page
   

- Advertisement -