Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit number of records queried

Status
Not open for further replies.

Mich

IS-IT--Management
Dec 26, 2000
452
US
I have a query to run against a db with millions and millions of entries. I'd like to test the query before running it against the entire db.
Is there a way to run the query against only the first 1000 entries? 5000 entries? X entries?

In other words, if my query is 'select * from header', can I reword it to 'select * from header obs = 1000' or something like that?

Please help this SQL newbie...thanks
 
Most DBMS have this type of feature but they use different syntax. Which DBMS are you using?
 
Doesn't this query the full database and return only the first 500 rows? If so, I need a statement that will only query the first X rows and return the results off of that.

Thanks,
Mick
 
No. The processing of the query will stop when 500 rows have been found.
 
Mick,
Are you saying that you want a query that examines the 1st 500 rows and returns however many rows that match the selection criteria
or
a query that examines however many rows it is necessary to return 500 rows in the output?
 
select top 500 *
from your_table


"order by" will deterimine which 500 will be returned.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top