Enhancing database security
Recently, several inconsistencies have been discovered on the Fresh Fruit Delivery company's database server.
The IT Security team does not have an auditing process to find out when users are connecting to the database and track breaking changes back to the responsible user.
You are asked to help the Security team by implementing a new trigger based on their requirements.
Due to the complexity of this request, you should build the INSERT
statement in the first step and use it to create the trigger in the second step.
This exercise is part of the course
Building and Optimizing Triggers in SQL Server
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Save user details in the audit table
INSERT INTO ___ (___, ___, ___, ___)
SELECT ORIGINAL_LOGIN(), GETDATE(), @@SPID, client_net_address
-- The user details can be found in SYS.DM_EXEC_CONNECTIONS
FROM SYS.DM_EXEC_CONNECTIONS WHERE ___ = @@SPID;