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.
Author |
Topic |
overthetop
Starting Member
18 Posts |
Posted - 2006-08-09 : 06:39:37
|
Hiwhat is the best way to page a table in sql server 2000. I think that using temp tables is out of the question. So can you tell me what is the right way and if someone can give me link to read more :)10x |
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-08-09 : 07:42:11
|
http://weblogs.sqlteam.com/jeffs/archive/2003/12/22/672.aspxRyan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
overthetop
Starting Member
18 Posts |
Posted - 2006-08-10 : 09:09:52
|
quote: Originally posted by RyanRandall http://weblogs.sqlteam.com/jeffs/archive/2003/12/22/672.aspxRyan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part.
yes but if you don't have an identity column? For example if you have a table [id], [name] ([id] is guid) how can you do the paging? |
 |
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-08-10 : 10:27:26
|
quote: Originally posted by overthetop
quote: Originally posted by RyanRandall http://weblogs.sqlteam.com/jeffs/archive/2003/12/22/672.aspxRyan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part.
yes but if you don't have an identity column? For example if you have a table [id], [name] ([id] is guid) how can you do the paging?
The example in the article uses an identity column, but I don't think you need one to use the method suggested in the article. I think you just need something unique to order by - which may be one or many columns.Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
overthetop
Starting Member
18 Posts |
Posted - 2006-08-11 : 15:04:14
|
I'm sorry it works finedeclare @startName nvarchar(50)declare @startGuid uniqueidentifierdeclare @rowIndex intdeclare @pageSize intset @rowIndex = 3set @pageSize = 4set rowcount @rowIndexselect @startGuid = [guid], @startName = [name]from Table_2order by [name], [guid]set rowcount @pageSizeselect [guid], [name]from Table_2where [name] > @startName or ([guid] > @startGuid and [name] = @startName)order by [name], [guid]set rowcount 0but I can't understand why it works. I am sorry if this looks stupied but I am not so good in t-sql. What is the meaning of this...where [name] > @startName or ([guid] > @startGuid and [name] = @startName)...what this [name] > @startName means? What this compares? Please someone can explain me the logic. HELP You are right this time :) "Solutions are easy. Understanding the problem, now, that's the hard part." |
 |
|
|
|
|
|
|