An INSERT statement with output.
@ @identity can only return the identity column that was last produced by the current session. If you insert more than one statement at a time. You need to return the identity columns for these automated productions. Then the OUTPU comes in handy.
int, v nvarchar (200))
into T1 (Datacol)
Output Inserted.keycol, Inserted.datacol
Into @temp
From @temp
--------------------
INSERT INTO Downlog
Output
NEWID (), inserted.id,inserted.id,inserted.id, Inserted.id,getdate () into Matchorderlog
VALUES (' 123444 ', ' Aaaaaa.txt ', GETDATE (), 1,1,1)
SELECT * FROM Matchorderlog
The DELETE statement with the output and the UPDATE statement are similar.
The DELETE statement can manipulate the deleted temporary table. The essence of update is that delete and insert can operate inserted and updated two tables at a time.
Update loanee Set [email protected],updatetime=getdate ()
Output
NEWID (), deleted.id,deleted. Applicationid,deleted. Matchorder, inserted. Matchorder,getdate () into Matchorderlog
where [email protected] and deletestate=0 and loaneetype=0
============================
deleted. Parameter name is the value before the change
inserted. Parameter names are changed or inserted argument values
Use format: INSERT into table name output inserted. parameter name, inserted. Parameter name 2 into record table values (table value, table value 2, table value 3 ...)
Update table Name set parameter name = parameter value, parameter name 2 = parameter value 2 ... output inserted. parameter name, inserted. Argument name 2 into record table where condition ...
SQL Server Output Usage notes