In different databases, the syntax of selecting top N records are slightly different. They may also differ from ISO standards.

In SQL Server, use TOP (N) to retrieve the first N records in the table. Remember to replace N with one actual number.

Code snippet

SELECT TOP (N) * FROM TableName;
info Last modified by Raymond at 2 years ago * This page is subject to Site terms.

More from Kontext

local_offer mssql local_offer t-sql

visibility 20
thumb_up 0
access_time 7 months ago

This code snippet shows how to calculate time differences.

open_in_new View open_in_new Code snippets

local_offer mssql local_offer t-sql

visibility 11
thumb_up 0
access_time 7 months ago

This code snippet shows how to convert string to date.

open_in_new View open_in_new Code snippets

local_offer mssql local_offer t-sql

visibility 15
thumb_up 0
access_time 7 months ago

JSON is commonly used in modern applications for data storage and transfers. Pretty much all programming languages provide APIs to parse JSON. 

open_in_new View open_in_new Code snippets

local_offer mssql local_offer t-sql

visibility 15
thumb_up 0
access_time 7 months ago

In Oracle database, you can select from dual table if you only want to return a one row result set. In many other databases, the query engine supports select directly from constant values without specifying a table name. 

open_in_new View open_in_new Code snippets

info About author

Dark theme mode

Dark theme mode is available on Kontext.

Learn more arrow_forward

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.


Learn more arrow_forward