Optimize SQL Using SET ROWCOUNT

Posted by Techie Cocktail | 2:19 PM | | 5 comments »

SET ROWCOUNT causes SQL Server to stop processing the query after the specified number of rows are returned.

Once the ROWCOUNT is set then the following queries would return those many number of rows in the resultset irrespective of any filtering or conditions applied.

To turn off this option, set the ROWCOUNT to 0. This command can be executed by any
users. The user need not have any special permissions to execute this command.


Syntax:
SET ROWCOUNT <number> | <@number_var>

It is the best way to optimize a query, if we are aware of how many records we would
need at a time. For example, if you are performing custom paging for GridView in
asp.net 2.0, then you can set the query to return only the required number of rows as set in the PageSize property of the GridView.

Visit MSDN for more details with examples: MSDN

5 comments

  1. tike mik // February 2, 2021 at 5:35 AM  

    But let me tell you that being a successful Internet marketer means being successful for the long run - and you cannot be successful in the long run if you start your career as a fraudster. SEO Antwerpen

  2. tike mik // February 23, 2021 at 10:01 PM  

    You may be curious about how sunlight is transformed into electricity. When the sun shines onto a solar cell, photons (light particles) are bombarded onto the upper surface of the cell. Each light particle then carries its energy down through the cell. www.zonnepanelen-soloya.nl/beste-zonnepanelen-merken

  3. tike mik // March 25, 2021 at 1:38 AM  

    Internet marketing is falling over themselves trying to shift dollars from offline to online marketing. I believe the idea is that network marketing will give them better to reduce the U.S. dollar in a tight economic returns. While it is certainly a solid strategy for mobile Internet, it pays to put it a little thought, the first: Verify your infrastructure. SEO zoekmachine optimalisatie

  4. tike mik // April 3, 2021 at 5:43 AM  

    In stand alone solar power systems batteries are charged with surplus electricity for night-time use. The life cycle of a battery is what determines its suitability for use with solar cells. The amount of electricity required, along with the size of the battery, will determine the number of hours energy will last during periods of no sunlight. Zonnepanelen plaatsen

  5. tike mik // November 2, 2021 at 1:12 AM  

    Lean into yourself and let your light shine. Tell your stories. You are who you are, and there's a tribe out there waiting to meet and support you and your business! instagram marketing