How to use SQL output clause to output insert, update, delete results to a new temporary table?

I'm currently trying to execute updatein SQL Server (but it could be any DML statement that supports it output) , and I would like to put the output in a local temp table, for example:

update
    dbo.MyTable
set
    MyField = 30
output
    inserted.MyKeyField
into
    #myTempTable
from
    dbo.MyTable as t
where
    f.MyFilteredField = 8 

I know that the syntax is correct, as in the documentation for the sentence output(my selection):

output_table

Specifies the table into which the returned rows are inserted, instead of being returned to the caller. output_table may be a temporary table .

, , , into select .

:

'#myTempTable'.

output (inserted deleted) temp?

+5
1

output , , , output, :

select t.MyKeyField into #myTempTable from dbo.MyTable as t where 1 = 0

: select into , create table . , , output.

" " , ​​ DML ( ).

+11

All Articles