Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql-server

Is there any way in SQL Server 2012 to identify who has changed the database name? Is there any audit log or some thing that would help?

like image 343
variable Avatar asked Oct 20 '25 01:10

variable


1 Answers

The rename operation will be written to TLOG no matter how you do it.

I did a small test and renamed a database. This rename operation is written to the TLOG as you can see in below screenshot:

enter image description here

You can read the log and know the name using this query:

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

This is subject to below clauses

  1. Your master db is in full recovery model
  2. Even if your master db is not in full recovery model, you may get that data, if that is not truncated

Also note reading log on live production database is not recommended, so I advise taking backups of TLOG and reading them seperately

like image 88
TheGameiswar Avatar answered Oct 22 '25 05:10

TheGameiswar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!