Compartir a través de


Cómo crear una auditoría en el nivel de servidor

Antes de poder crear una especificación de auditoría en el nivel de servidor, deberá crear y configurar un objeto SQL Server Audit que se pueda usar en la auditoría.

Para realizar esta tarea debe usar el Editor de consultas de SQL Server Management Studio para llevar a cabo el siguiente procedimiento. En el ejemplo siguiente se crea una auditoría en el nivel de servidor de acciones de inicio de sesión no conseguidas, enviando la auditoría al registro de eventos de la aplicación para Windows.

Para crear una auditoría en el nivel de servidor

  1. Cree un objeto Audit y defina el destino.

    /* Create the SQL Server Audit object, and send the results to the 
    Windows Application event log. */
    CREATE SERVER AUDIT Test_SQL_Server_Audit
        TO APPLICATION_LOG
        /* The Queue Delay is set to 1000, meaning one second 
             intervals to write to the target. */
        WITH ( QUEUE_DELAY = 1000,  ON_FAILURE = CONTINUE);
    GO;
    
  2. Cree la especificación de auditoría en el nivel de servidor y asígnela al objeto Audit.

    /* Create the Server Audit Specification object by using an Audit  event group. */
    CREATE SERVER AUDIT SPECIFICATION Test_Server_Audit_Specification
    FOR SERVER AUDIT Test_SQL_Server_Audit
        ADD (FAILED_LOGIN_GROUP);
    
  3. Habilite la auditoría.

    /* Enable the audit. */
    ALTER SERVER AUDIT Test_SQL_Server_Audit
    WITH (STATE = ON);
    GO