Mirror

Retrieve just 1 row from a table (SQL) (Views: 300)


Problem/Question/Abstract:

How do i retrive just 1 row from a sql table

Answer:

found this nice sql-tip for ya::

you have 2 options:

- use TOP function in sql

-----start
SELECT TOP 1 * FROM myTable
-----end

- by setting the rowcount before selecting in sql

-----start
SET ROWCOUNT 1
SELECT * FROM myTable
-----end

Note: If you use SET ROWCOUNT and you have a batch of commands, make sure you SET ROWCOUNT immediately before the SELECT statement. If you SET ROWCOUNT before an UPDATE or DELETE it will limit the number of rows affected by those operations.

<< Back to main page