how can I Update top 100 records in sql server

前端 未结 7 1029
醉梦人生
醉梦人生 2020-11-27 10:03

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

相关标签:
7条回答
  • 2020-11-27 10:46

    for those like me still stuck with SQL Server 2000, SET ROWCOUNT {number}; can be used before the UPDATE query

    SET ROWCOUNT 100;
    UPDATE Table SET ..;
    SET ROWCOUNT 0;
    

    will limit the update to 100 rows

    It has been deprecated at least since SQL 2005, but as of SQL 2017 it still works. https://docs.microsoft.com/en-us/sql/t-sql/statements/set-rowcount-transact-sql?view=sql-server-2017

    0 讨论(0)
提交回复
热议问题