A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database.
Triggers that run after an update, insert, or delete. .Triggers are used to enforce data integrity and business rules such as automatically updating summary data. It allows to perform cascading delete or update operations.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[trgAfterInsert] ON [dbo].[UserTable]
FOR INSERT
AS
declare @empid int;
declare @empname varchar(100);
declare @audit_action varchar(100);
select @empid=i.ID from inserted i;
select @empname=i.UserName from inserted i;
set @audit_action='Inserted Record -- After Insert Trigger.';
INSERT INTO [TestPB].[dbo].[tt]
([id]
,[name]
,[audit_action])
VALUES
(@empid,
@empname
,@audit_action)
PRINT 'AFTER INSERT trigger fired.'
Hope this can help You friends.