Monday, March 19, 2012

displaying some predefined no. of rows

hi,

i wanted to know if there is any sql statement that enables the query to display say first '10' rows only.

Eg: suppose

SELECT * from Location;

returns 25 rows and i want only 10 rows in that to be displayed.

How can this be done? Help please.

You can use TOP statement like

SELECT TOP 10 * from Location

Is good to include order by for example table identity column if you would like to receive last inserted records

SELECT TOP 10 *
from Location
order by loc_ID desc

No comments:

Post a Comment