Home > SQL server Basics > Update top N record in SQL Server

Update top N record in SQL Server

June 9, 2009 4 Comments
Disclaimer : This tutorial is meant for beginners and for anyone who find it useful. The main purpose of this post to keep everything i find useful for future reference for myself and for others.

SQL statement to update top N records

update daily_sales
set is_calc='Y'
from daily_sales
inner join (select top 100 * from daily_sales where product_category='CA') a
on a.unique_record_id=daily_sales.unique_record_id
and a.milestone_code=daily_sales.milestone_code

Source is SQLServerCentral

Tags: SQL server Basics T-SQL update top N

Comments:4

  1. How to Make Thousands of Dollars Posting Links on Google
    June 11, 2009 at 1:20 am

    Thanks for posting, I’ll definitely be subscribing to your blog.

  2. Maxim Fateev
    August 28, 2009 at 7:34 am

    You can just use

    update top(100) daily_sails

  3. BALA SINGAM
    August 28, 2009 at 11:36 am

    Thanks Maxim Fateev.

    Its seems much simpler solution. Thanks for sharing!

  4. Libya
    October 14, 2009 at 10:14 pm

    Thanks for sharing, it was helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>