how can I Update top 100 records in sql server

前端 未结 7 1069
醉梦人生
醉梦人生 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:32

    You can also update from select using alias and join:

    UPDATE  TOP (500) T
    SET     T.SomeColumn = 'Value'
    FROM    SomeTable T
            INNER JOIN OtherTable O ON O.OtherTableFK = T.SomeTablePK
    WHERE   T.SomeOtherColumn = 1
    

提交回复
热议问题