Using cross apply in update statement

后端 未结 1 1795
庸人自扰
庸人自扰 2021-01-17 07:42

Is it possible to use the cross apply clause in the from part of an update statement, in SQL Server 2005?

相关标签:
1条回答
  • 2021-01-17 08:08

    You where right, Albert. I made some tests and found that it's possible, indeed. The use is the same as in a SELECT statement. For example:

    UPDATE some_table
    SET some_row = A.another_row,
        some_row2 = A.another_row/2
    FROM some_table st
      CROSS APPLY
        (SELECT TOP 1 another_row FROM another_table at WHERE at.shared_id=st.shared_id) AS A
    WHERE ...
    
    0 讨论(0)
提交回复
热议问题