sqlsql-servert-sqlsql-update

How can I update top 100 records in SQL server?


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?


Solution

  • Note, the parentheses are required for UPDATE statements:

    update top (100) table1 set field1 = 1