从插入的+内连接返回OUTPUT并返回值

时间:2013-12-12 21:02:20

标签: sql sql-server tsql

我用这种方式锁定记录:

UPDATE TOP (10) TABLEA SET STATUS = 5 
                         OUTPUT inserted.*
                         FROM TABLEA A
                         INNER JOIN TABLEB B 
                         ON A.EMAIL = B.VALUE 

现在,是否可以返回已连接表的值?

1 个答案:

答案 0 :(得分:1)

DECLARE @T TABLE (Status INT)

UPDATE A 
SET STATUS = 5 
OUTPUT inserted.STATUS   INTO  @T(Status)
FROM TABLEA A INNER JOIN TABLEB B 
ON A.EMAIL = B.VALUE 

SELECT * FROM @T