开发者

Using cross apply in update statement

开发者 https://www.devze.com 2023-04-06 01:56 出处:网络
Is it possible to use the cross apply clause in the from part o开发者_运维技巧f an update statement, in SQL Server 2005?You where right, Albert. I made some tests and found that it\'s possible, indeed

Is it possible to use the cross apply clause in the from part o开发者_运维技巧f an update statement, in SQL Server 2005?


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 
    st
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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号