Renaming logical file names

  • Hi

    I was wondering if anyone has a script to rename the Logical file names in sql.

    For example

    DMedsol258_Data

    DMedsol258_log

    DMedsol258_Data_120

    Need to be renamed tothe following

    DMedsol_Data

    DMedsol_log

    DMedsol_Data_120

    We have quiet a few databases to change.

    Thanks

  • From BOL (under ALTER DATABASE):

    Moving a file to a new location

    The following example moves the Test1dat2 file to a new directory.

    Note:

    You must physically move the file to the new directory before running this example. Afterward, stop and start the instance of SQL Server or take the AdventureWorks database OFFLINE and then ONLINE to implement the change.

    USE master;

    GO

    ALTER DATABASE AdventureWorks

    MODIFY FILE

    (

    NAME = Test1dat2,

    FILENAME = N'c:\t1dat2.ndf'

    );

    GO

    If you only need to modify the name of the file use this option of the ALTER DATABASE command:

    MODIFY FILE ( NAME = logical_file_name, NEWNAME = new_logical_name )

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply