|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Begin Next End problems?Please take a look at this code USE Northwind GO DECLARE @Index INT SET @Index = 0 WHILE @Index <= 8 BEGIN SET @Index = @Index + 1 SELECT TOP 2 * FROM Employees WHERE EmployeeID = @Index END GO This will give me 1 record at the time 1 1 2 3 .... 9 and this code USE Northwind GO DECLARE @Index INT SET @Index = 0 WHILE @Index <= 8 BEGIN SET @Index = @Index + 1 SELECT TOP 2 * FROM Employees --WHERE EmployeeID = @Index ------------ not include this one END GO will give me 2 records at the time but 1 2 1 2 .... 1 2 How do I code this to retrieve 2 records but in consecutive order like 1 2 3 4 ..... 8 9 Thank you all at advance. Oded Dror Email: odedd***@cox.net It looks like you are trying to do paging
If so Refer this http://www.windowsitpro.com/Article/ArticleID/40505/40505.html?Ad=1 -- Show quoteThanks Ravi "Oded Dror" wrote: > Hi there > > Please take a look at this code > > USE Northwind > GO > DECLARE @Index INT > SET @Index = 0 > WHILE @Index <= 8 > BEGIN > SET @Index = @Index + 1 > SELECT TOP 2 * FROM Employees > WHERE EmployeeID = @Index > END > GO > > This will give me 1 record at the time 1 > 1 > 2 > 3 > .... > 9 > > and this code > > USE Northwind > GO > DECLARE @Index INT > SET @Index = 0 > WHILE @Index <= 8 > BEGIN > SET @Index = @Index + 1 > SELECT TOP 2 * FROM Employees > --WHERE EmployeeID = @Index ------------ not include this one > END > GO > > will give me 2 records at the time but > 1 > 2 > > 1 > 2 > .... > 1 > 2 > > How do I code this to retrieve 2 records but in consecutive order like > > 1 > 2 > > 3 > 4 > > ..... > > 8 > 9 > > Thank you all at advance. > > Oded Dror > Email: odedd***@cox.net > > >
Other interesting topics
|
|||||||||||||||||||||||