4

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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
variable
  • 8,262
  • 9
  • 95
  • 215
  • try [this](http://stackoverflow.com/questions/5299669/how-to-see-query-history-in-sql-server-management-studio) – XtremeBaumer Apr 27 '17 at 11:04
  • The rename can be done via UI and also via SQL script. Do you know if there is any sort of audit log? – variable Apr 27 '17 at 11:07
  • SQL Server can be configured to audit a lot of things https://learn.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-database-engine – ta.speot.is Apr 27 '17 at 11:08
  • 1
    @variable perhaps you should be looking at *why* this happened. *Why* doesn't every developer have his own server installation for coding? SQL Server Dev is free. *Express* has all programability features of Enterprise nowadays. Keeping changes in sync doesn't justify using a single database. If you do so, it means you have a version control problem easily solved by using SSDT, Database Projects and any kind of version control, like Git – Panagiotis Kanavos Apr 27 '17 at 11:34

1 Answers1

5

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
TheGameiswar
  • 27,855
  • 8
  • 56
  • 94