开发者

Output clause with left join, how to?

开发者 https://www.devze.com 2023-03-10 19:38 出处:网络
Is it possible to do something along those lines: DELETE TOP开发者_开发知识库(1) m FROM MyTable m

Is it possible to do something along those lines:

DELETE TOP开发者_开发知识库(1) m
FROM MyTable m
OUTPUT deleted.*
LEFT JOIN MyOtherTable ON MyOtherTable.SomeColumn=s.SomeColumn

I know this works:

DELETE TOP(1) 
FROM MyTable
OUTPUT deleted.*

And this also works (although pointless):

DELETE TOP(1) m 
FROM MyTable m
LEFT JOIN MyOtherTable ON m.SomeColumn=MyOtherTable.SomeColumn


Move the OUTPUT clause to before the JOIN

DELETE TOP(1) m 
OUTPUT deleted.* 
FROM MyTable m 
LEFT JOIN MyOtherTable ON MyOtherTable.SomeColumn=s.SomeColumn 
0

精彩评论

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