SET ROWCOUNT Function in SQL Server Last Updated : 10 Feb, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The ROWCOUNT Set Function causes the server to stop the query processing after the specified number of records is returned. One may limit the number of records returned by all subsequent SELECT statements within the session by using the keyword SET ROWCOUNT. Or we can say that this function causes Transact-SQL statements to stop processing when they have been affected by the specified number of records. This includes triggers. If the rowcount has a smaller value then, it will override the SELECT statement and TOP keyword. Also, it is used to set at execute or run time and not at parse time. This function affects all the statements present in the current database session until the next SET ROWCOUNT function is arrive or until the session is terminated. Syntax: SET ROWCOUNT { number or variable } If the value of SET ROWCOUNT is set to zero then that means we turn off this feature. Example 1: The following table contains the details of the product: ProductIDProductNameSupplierIDCategoryID1Azithral112Augmentin113Ascoril124Azee225Alegra22Now we use the following query to get the first three rows of the table: SET ROWCOUNT 3; SELECT * FROM products; Output: Example 2: The following table contains the details of the doctors: DoctorIDDoctorNameTiming102Aman10 PM103Mohit11 PM104Rohit9 AM105Sumit10 AM106Anamika2 PMNow we use the following query to get the first four rows of the table: SET ROWCOUNT 4; SELECT * FROM products; Output: Comment More infoAdvertise with us Next Article SQL Server Group Functions K krrishsai648 Follow Improve Article Tags : Computer Science Fundamentals School Learning Class 12 Similar Reads SQL Server Group Functions The group function in SQL Server provides a powerful tool for performing calculations on groups of rows, allowing you to group data based on specific criteria. This function is important when you want to analyze and summarize information from multiple records in a data structure. The basic group fun 3 min read GROUPING ID Function in SQL Server SQL Server is a Relational Database Management System that is used to create and manipulate the database. It provides advanced security measures like encryption, access control, and auditing to protect sensitive data from unauthorized access. It Supports a wide range of data types, including structu 6 min read SQL Server Window Functions ROWS vs. RANGE We will cover the important concept of the MS SQL Server which is the difference between Row and Range. The confusion between the row and range and where it is used will be eradicated by reading this article. So, be with the flow of the article for a better understanding and keep practicing side by 5 min read Count(*) vs Count(1) in SQL Server In SQL Server, the COUNT() function is used to return the number of rows in a query result. There are different ways to use the COUNT() function such as COUNT(*) and COUNT(1). Although they produce the same result, there are subtle differences in how they work internally.In this article, we will try 4 min read Deleting a Column in SQL Server Structure Query Language (SQL) is a standard language to manipulate and manage the database. SQL is a very powerful language for managing the database. SQL Server Delete command is one of the SQL commands that is used to remove the data that is not useful or due to which inconsistency occurred in th 5 min read How to Count Based on Condition in SQL Server? In SQL Server, the COUNT() function is also utilized for tallying the number of records within a table. This article intends to explore the query, focusing on incorporating conditions into the COUNT() function in SQL Server. The COUNT() function in SQL Server is commonly utilized to count all record 4 min read Like