Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 :
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 :
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 27-Jan-13 21:24pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

 
-- 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
 
  Permalink  
Comments
Member 3892343 at 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 at 28-Jan-13 3:02am
   
"invalid object name #t"
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

no, no any error occures, bcoz i already tried it.
 
you are are making some mistake... just try again...
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,105
1 DamithSL 5,079
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,617
4 Kornfeld Eliyahu Peter 4,384


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100