Bala's Development Blog

.Net,SQL Server, ASP.Net ……

Update top N record in SQL Server

with 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

Written by BALA SINGAM

June 9th, 2009 at 12:12 am

4 Responses to 'Update top N record in SQL Server'

Subscribe to comments with RSS or TrackBack to 'Update top N record in SQL Server'.

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

  2. You can just use

    update top(100) daily_sails

    Maxim Fateev

    28 Aug 09 at 7:34 am

  3. Thanks Maxim Fateev.

    Its seems much simpler solution. Thanks for sharing!


    28 Aug 09 at 11:36 am

  4. Thanks for sharing, it was helpful.


    14 Oct 09 at 10:14 pm

Leave a Reply