SQL Server @@ROWCOUNT, @@IDENTITY

@@ROWCOUNT Get affected rows when do UPDATE / DELETE / INSERT

Note that:
@@ROWCOUNT is reset after every statement so you must retrieve the value immediately with no intervening statements.

Pasted from <https://stackoverflow.com/questions/8577632/how-can-i-get-number-of-deleted-records>

@@IDENTITY

After an INSERT, SELECT INTO, or bulk copy statement is completed, @@IDENTITY contains the last identity value that is generated by the statement. If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL. If multiple rows are inserted, generating multiple identity values, @@IDENTITY returns the last identity value generated.

Pasted from <https://docs.microsoft.com/en-us/sql/t-sql/functions/identity-transact-sql?view=sql-server-2017>

原文地址:https://www.cnblogs.com/frankcui/p/15633958.html