The OUTPUT clause returns information on rows that are affected by an INSERT, UPDATE, DELETE, or MERGE statement. This information can be output to the console or saved to a target table and is often used for auditing purposes.
Example:
CREATE TABLE [Customer]( [CustomerID] [int] IDENTITY, [FirstName] [varchar](50) NULL, [LastName] [varchar](50) NULL, ) DECLARE @Customer_Inserted_Log TABLE( [CustomerID] [int], [FirstName] [varchar](50) NULL, [LastName] [varchar](50) NULL ) INSERT INTO Customer OUTPUT inserted.* INTO @Customer_Inserted_Log -- without this INTO line will display the result to the console VALUES('Lionel', 'Messi') SELECT * FROM @Customer_Inserted_Log