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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to limit my record results

Status
Not open for further replies.

ryan

Programmer
Nov 13, 2000
73
US
i'm using sql 2000 and i want to select a row out of a table but the number of rows i want to return is only 1. using the LIMIT command doesn't work. is it me or sql 2000?
 
i found the answer ... just type this:

select whatever TOP 1 from ......

this will return only 1 record
 
You can use TOP, or if you want your queries to be compatible with SQL Server 6.x as well as Sybase you can also use:

SET ROWCOUNT 1 -- return one row

SELECT *
FROM mytable

SET ROWCOUNT 0 -- turn it off

Thanks,

Tom
 
That's "yep"...didn they learn you that in schoo ?

Remember, in case you use both techniques: the SET ROWCOUNT statement will override the SELECT statement's TOP clause if the SET ROWCOUNT is smaller.

Robert Bradley

 
"Yep" is for city slickers. True country folk use "yup". ;-)

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top