带左连接的输出子句,如何?

时间:2011-06-07 14:09:46

标签: sql sql-server

是否有可能沿着这些方向做点什么:

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

我知道这有效:

DELETE TOP(1) 
FROM MyTable
OUTPUT deleted.*

这也有效(尽管毫无意义):

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

1 个答案:

答案 0 :(得分:25)

OUTPUT子句移到JOIN

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