Stewart "Arturius" Campbell (9/10/2012)
Alternatively, in theOUTPUT Inserted.* into delkk
line, remove the " into delkk" statement, i.e. the OUTPUT statement should reflect( Orderdatum, txtKortingBdr,Klantnummer, Tal)
OUTPUT Inserted.*
That's what I thought initially, however, if you try to run the code with the modification suggested it
presents the following error:
Msg 10727, Level 15, State 1, Procedure DelKK2jaar, Line 17
A nested INSERT, UPDATE, DELETE, or MERGE statement is not allowed on either side of a JOIN or APPLY operator
I don't think the way the OP has written the code is valid Sql in any case.
I think in order to do what he wants to do he would have to:
Run the nested insert with the output clause into a #temp table or variable
Do the Join on that to perform any other actions.