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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 count(*) and fetch the records based on the condition.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-09-15 : 08:41:08
Narayan writes "I have a query that fetches say around billion records,
user can get only 100 records (limit)
if my query(1billion) is fetching more than user is allowed..i need not give o/p (thats the fetch),else we ll give the o/p
I take count(*) for the query..check for the condition that it is less than the users limit,there is a overhead on the performance.

Is there any possibility to get the count(*) of the records from select and simultaneously print the records as it completes the condition.


Thanks,
NarayanIndra."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-09-15 : 08:49:15
Please tell me you were using a cursor to fetch a billion rows...I need a good laugh.

This will work much better:

SELECT TOP 100 * FROM myTable

You didn't say if you were using SQL Server (I'm guessing you're not), so this may not work in a different database software.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-09-15 : 08:53:16
if u mean:
run
select * from ...
and it would be doing
'selected 1000 records...'
'selected 2000 records...'
'selected 3000 records...'
...

then no.
if u mean something else, give us more info. because it sounds to me you want to do what i suggested...

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -