How to rename the Physical Database Files

Abs picture Abs · Jan 21, 2011 · Viewed 34.8k times · Source

I have used tsql to detach a database like this:

EXEC sp_detach_db @dbname = 'my_db'

I then made use of PHP to rename the physical files. I was able to rename the mdf file but not the ldf file! I even tried a dos command REN but that didn't work for the ldf file either!

I wanted to ask, is there something special about the physical log files that allow it not to be renamed?

Is there a better way of doing this?

Thanks all

Answer

Babak picture Babak · Aug 29, 2015

Detach the Database, Rename the files, Attach it again.