Trigger to Log Time, Date, and User for Inserts, Updates, and Deletes

This technical problem involves designing a trigger that will log the time, date, and user who performed an insert, update, or delete on a table.

Problem

Design a trigger that will log the time, date, and user who performed an insert, update, or delete on a table.
Example input:
N/A
Example output:
Table1
| Time                | Date       | User       |
|---------------------|------------|------------|
| 13:00:00.0000000     | 12/12/2018 | JohnSmith  |
| 14:00:00.0000000     | 12/12/2018 | JaneDoe    |

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
CREATE TRIGGER [dbo].[tr_Table1_Log]
ON [dbo].[Table1]
AFTER INSERT, UPDATE, DELETE
AS
BEGIN
	SET NOCOUNT ON;

	INSERT INTO [dbo].[Table1_Log]
		([Time], [Date], [User])
	SELECT
		GETDATE(),
		GETDATE(),
		SUSER_SNAME()
END

/*

The trigger is optimal because it is a single statement that will be executed after an insert, update, or delete.

*/

A.I. Evaluation of the Solution

The trigger is optimal because it is a single statement that will be executed after an insert, update, or delete.

Evaluated at: 2022-11-14 00:15:41