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.
Este ejercicio forma parte del curso
Building and Optimizing Triggers in SQL Server
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
-- 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;