SQL TOP Clause - SQL Select Top Statement



SQL TOP Clause

  • When fetching data from an SQL table, the SQL TOP clause serves to limit the number of rows returned by a SELECT query in SQL Server. Moreover, it can also be applied with UPDATE and DELETE statements to confine the resulting records.
  • For example, when dealing with a substantial amount of data stored in a database table, and there's a need to operate on only the first N rows, the TOP clause can be employed in your SQL Server query.

Syntax

SELECT TOP value column_name(s) FROM table_name

Example

  • Currently, we utilize the TOP clause to retrieve the first 4 records from the CUSTOMERS table without specifying any conditional clauses like WHERE or ORDER BY.
SELECT TOP 2 * FROM tbl_Wikitechy

Output

sql-top-clause


Related Searches to SQL TOP Clause - SQL Select Top Statement