是否有可能沿着这些方向做点什么:
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
答案 0 :(得分:25)
将OUTPUT
子句移到JOIN
DELETE TOP(1) m
OUTPUT deleted.*
FROM MyTable m
LEFT JOIN MyOtherTable ON MyOtherTable.SomeColumn=s.SomeColumn