Something like this can act as a base to your script: If you are talking about Login to the instance and if you already capture the successfull and failed login into the SQL Error log, you could read from the error log instead (sp_readerrorlog) and save it to a table.īoth option could be scripted and run in a SQL job so that you keep updating the table. If you are talking about the connection to a database, you could use an extended event (or a trace) and run a job that will read from the file created by it to store the data into a Table. You can also make a system trigger but why bother when an audit policy will do the job? Security | Audits → Right-click the newly created audit and select To view the SQL Server audit login trail, navigate to.In the “Audit action type” column, select “Failed Login Group”Īnd “Successful Login Group” → Click “OK” →Ĭreated server audit specification and select “Enable server audit.Type in an appropriate name → Select the new audit from the audit drop-down.Right-click “Server Audit Specification” and select “New Server Audit Specification” →. Right-click the newly created audit and select “Enable audit”. Server audit logs will be stored → Click “OK” →
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |