Select top N records in T-SQL / SQL Server

access_time 2 years ago visibility37 comment 0

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 copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Want to publish your article on Kontext?

Learn more

Kontext Column

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


Learn more arrow_forward

More from Kontext

local_offer mssql local_offer t-sql

visibility 58
thumb_up 0
access_time 12 months ago

This code snippet shows how to convert string to date.

local_offer SSIS local_offer mssql

visibility 13316
thumb_up 0
access_time 7 years ago

SSIS (SQL Server Integration Service) provides a number of convenient tasks to enable data integration. Exporting data from database to Excel file is a common task in ETL (Extract, Transform, Load) projects. Constantly the users/customers may raise format request regarding the Excel extract. To ...

local_offer mssql local_offer t-sql

visibility 58
thumb_up 0
access_time 12 months ago

This code snippet shows how to convert string to date.

About column

Code snippets and tips for various programming languages/frameworks.

rss_feed Subscribe RSS