question

thennarasu avatar image
thennarasu asked

How to create a mail alert when anybody accesses the database

How do I create a mail alert that triggers when anybody (other than a select group of users) accesses a particular database? example: databseName :DBadmin Login:temp1 -dbowner Login:tem2 -dbowner Login:temp3 -(sysadmin permission) Login:temp4 -dbowner Send an alert mail if temp3 or temp4 hve accessed the database. That is, if they `SELECT, INSERT, DELETE` etc. This condition is not to apply to temp1 or temp2 logins.
sql-server-2008sql-server-2012mailalerts
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JohnM avatar image
JohnM answered
Your best bet for this type of tracking is probably SQL Audits. I don't know if you can wrap an email alert around them natively but I'm sure that you could write something to facilitate scanning the log files and then react accordingly. Reference: https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-database-engine Note: This feature is only available in the Enterprise edition of SQL Server 2008 & SQL Server 2012. Hope that helps!
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.