how can I Update top 100 records in sql server

Rajesh picture Rajesh · Jul 29, 2009 · Viewed 430.6k times · Source

I want to update the top 100 records in SQL Server. I have a table T1 with fields F1 and F2. T1 has 200 records. I want to update the F1 field in the top 100 records. How can I update based on TOP 100 in SQL Server?

Answer

Umair Ahmed picture Umair Ahmed · Jul 29, 2009

Note, the parentheses are required for UPDATE statements:

update top (100) table1 set field1 = 1