为什么这个查询无法运行?
select *
from ass
join (
UPDATE [dsa]
SET col1='123'
OUTPUT inserted.*) as ds on ass.dsaid = ds.ID
答案 0 :(得分:1)
你必须分两步完成。使用OUTPUT
子句转到变量,然后从该变量中选择:
DECLARE @tbl_out TABLE(ID int, col VARCHAR(10));
UPDATE [dsa] SET [col1] = '123'
OUTPUT inserted.* INTO @tbl_out
SELECT * FROM ass JOIN @tbl_out ds ON ass.dsaid = ds.ID
(未经测试)