Change Logical Filenames in SQL Server

I got a backup of a database from my co-worker, that i restored as "ABC" database.

It restored okay but when I check the logical named for both Data and Log file were "XYZ" and "XYZ_Log" respectively.

I just Googled for a solution and got a command to rename the logical files.

The command lines as below
    USE MASTER
    GO

    ALTER DATABASE DBName
    MODIFY FILE (NAME = ExistingLogicalDataFileName, NEWNAME='NewDataFileName')
    GO

    ALTER DATABASE DBName
    MODIFY FILE (NAME = ExistingLogicalLogFileName, NEWNAME=NewLogFileName)
    GO

If you want to visit the original article by Jon Galloway, click here



No comments:

Post a Comment