Click here to Skip to main content
13,051,502 members (46,833 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +
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
Posted 27-Jan-13 20:24pm
Rate this: bad
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
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"
Rate this: bad
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...

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2017
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