T-SQLpowered

MERGE

Using OUTPUT clause: MERGE INTO [dbo].[TargetTable] [trg] USING ( SELECT [ID], [Value], [OtherValue] FROM [dbo].[SourceTable] ) AS [src] ON 1 = 0 WHEN NOT MATCHED THEN INSERT ( [ID],[Value] ) VALUES ([src].[ID], [src].[Value]) OUTPUT [Inserted].[ID], [Inserted].[Value], [src].[OtherValue]  

Read more
T-SQLpowered

UPDATE

Examples for SQL Server 2025. Each block is a separate example. Replace the table and column names as needed; Id is assumed to be unique. Basics Values and expressions Large strings and binary data Values from another source Conditions and changed values CTEs and batches OUTPUT and variables SQL Server…
T-SQLpowered

INSERT - Basic

Insert one row with default values for all table columns: INSERT INTO [dbo].[SampleTable] DEFAULT VALUES SELECT INTO and specify a filegroup (2016 SP2+): SELECT * INTO [dbo].[SampleTable_Copy] ON [OtherFilegoup] FROM [dbo].[SampleTable]