Rajesh Rajesh - 3 months ago 9
SQL Question

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?

Answer

Note, the parentheses are required for UPDATE statements:

update top (100) table1 set field1 = 1