Insert Trigger
CREATE TRIGGER trig_addAuthor ON [dbo].[Emp]
FOR INSERT
AS
DECLARE @newName VARCHAR(100)
SELECT @newName = (SELECT ename FROM Inserted)
-- Print the name of the new author
PRINT 'New author "' + @newName + '" added.'
Update Trigger
CREATE TRIGGER trig_updateemp
ON emp
FOR UPDATE
AS
DECLARE @oldName VARCHAR(100)
DECLARE @newName VARCHAR(100)
IF NOT UPDATE(ename)
BEGIN
RETURN
END
SELECT @oldName = (SELECT ename FROM Deleted)
SELECT @newName = (SELECT ename FROM Inserted)
PRINT 'Name changed from "' + @oldName + '" to "' + @newName + '"'