Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello,
I have a database in sql server 2008, it loads too many records and the pc runs out of memory, I have used this sql syntax :
SQL
SELECT     TOP 10 *
FROM         (SELECT     ROW_NUMBER() OVER (ORDER BY owner) AS RowNumber, *, TotalRows = Count(*) OVER ()
FROM         Table_1) _tmpView
ORDER BY owner

and this :
SQL
SELECT     TOP (10) * FROM dbo.Table_1

It works both and returns the top 10 records, my problem is that when I want to navigate through vb .net 2008 application (using ADO, sqldataadapter) it stops to the last (10th) record, I want to load the next 10 records when I reach the last (10th) of the query. Any help.

Thank you
Kyriakos
Posted

no, no any error occures, bcoz i already tried it.

you are are making some mistake... just try again...
 
Share this answer
 
SQL
-- Just declare a variable "@index" in stored procedure and  pass it value from your              -- application, which will supply it 1,2,3...

declare @index int set @index = 3
select top ( 10 * @index) * into #t from dbo.tablename order by name
select * from #t order by name 
select top 10 * from #t order by name desc
drop table #t
 
Share this answer
 
Comments
Member 3892343 28-Jan-13 3:02am    
I have to create the temp table #t? if I run it as you coded it returns "invalid object #t" error.
Member 3892343 28-Jan-13 3:02am    
"invalid object name #t"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900