SQL Server: can we find out who renamed the database?

Is there a way in SQL Server 2012 to determine who changed the name of the database? Is there an audit trail or something to help?

+3


source to share


1 answer


The rename operation will be recorded in the TLOG no matter how you do it.

I did a little test and renamed the database. This rename operation is recorded in the TLOG, as you can see in the screenshot below:

enter image description here

You can read the log and find out the name using this query:



select 
    suser_sname([transaction sid]) as username,* 
from 
    fn_dblog(null,null)

      

This falls under the points below

  • Your db master is in full recovery model.
  • Even if your master db is not in full recovery model, you can still get this data if it is not truncated.

Also note that the read log on a live database is not recommended, so I advise you to take TLOG backups and read them separately

+5


source







All Articles