Error when creating Audit Specification in SQL Server database

Babawale Dawodu 110 Reputation points
2023-10-03T14:30:16.0266667+00:00

Hi, I'm trying to create an Audit specification called SuccessfulLoginAttempt to track all successful connections to our SQLServer 2019 standard edition. I have already created the Server Audit but whenever I run the create script for audit specification, I get the error 'Incorrect Syntax near 'SUCCESSFUL_LOGIN_GROUP'

Here is my script;

CREATE DATABASE AUDIT SPECIFICATION SuccessfulLoginAttempt

FOR SERVER AUDIT LoginAttempt

ADD (SUCCESSFUL_LOGIN_GROUP)

WITH (STATE=ON);

GO

What's wrong with the syntax? hopefully, Someone can help. Thanks in advance

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-10-04T05:51:07.9366667+00:00

    Hi @Babawale Dawodu

    Do you want to create a database audit specification or a server audit specification?

    Example of creating a server audit specification:

    CREATE SERVER AUDIT SPECIFICATION HIPAA_Audit_Specification  
    FOR SERVER AUDIT HIPAA_Audit  
        ADD (FAILED_LOGIN_GROUP)  
        WITH (STATE=ON);  
    GO  
    

    If you change your syntax to create a server audit specification, the error seems to disappear.

    Best regards,

    Percy Tang

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-10-03T21:53:50.9133333+00:00

    I think it is because SUCCESSFUL_LOGIN_GROUP is a server event, so it cannot appear in a database audit.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.