Friday , November 22 2024

OUTPUT Clause in SQL Server(TSQL)

 

OUTPUT Clause transfers the records affected by the currently executed INSERT, UPDATE, or DELETE operations to the specified table. So we can easily capture newly created or updated or deleted records. The OUTPUT statement reads the newly inserted records from the INSERTED table,  deleted or updated records from the DELETED table. These tables are the virtual tables that are created at that time.

Create the table which we will update and insert some records.

Create the table which we will transfer the changes. Update the Telephone column where the City value is ‘İstanbul ‘ in the table  and transfer the affected values to table which we have created named ChangesTable. Lastly, Select the ChangesTable.

Another Example:

Loading

About Ahmet KAYMAZ

Leave a Reply

Your email address will not be published. Required fields are marked *