From the course: Microsoft SQL Server 2016: Query Data

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Using the TOP option

Using the TOP option - SQL Server Tutorial

From the course: Microsoft SQL Server 2016: Query Data

Start my 1-month free trial

Using the TOP option

- [Instructor] In this lesson we'll take a look at the use of TOP in SQL Server. TOP is a function that we can use in SQL Server to return a specified number of rows and we can manipulate how those rows get returned in the result set by using some other options. It's best to see examples of these so that it makes more sense from a visual perspective on how we can use TOP. Now to set a baseline, we're going to run a simple query on our Person.Address table, and just return all rows, and the reason that I want to do this is so you can get an understanding of how many rows actually exist in that table before we manipulate it with the TOP keyword. So if we run this first query, we can see that we're returning all columns and we're returning all rows or all records in the table, and we have a grand total of 19,614 rows. So that gives us a baseline from which we can take a look at how TOP will affect some of the queries in depending how we write them. Let's look at our next one here, which…

Contents