-- Create the Employee table
CREATE TABLE Employee (
eID INT PRIMARY KEY,
EName NVARCHAR(50),
Lastmodified DATETIME
);
insert into employee values(1, 'a',Null);
-- Create the trigger
CREATE TRIGGER tgn
ON Employee
AFTER INSERT
AS
BEGIN
-- Update the LastModified column with the current date and time for the newly inserted rows
UPDATE e
SET LastModified = GETDATE()
FROM Employee e
--INNER JOIN INSERTED i ON e.EmployeeID = i.EmployeeID;
END;
select * from employee;
insert into employee (eid,ename) values(2, 'b')
select * from employee;