1

I'm going to be moving a database from one server to another. Right now the name makes no sense and I'd like to change it. I found a answer here that makes me think it might be relatively simple. My question is three-fold.

1: Is there a reason I shouldn't rename the database? 2: Would the renaming be as simple as

RESTORE DATABASE [NewDatabaseName] 
FROM DISK = N'C:\OldDatabaseName.bak' 
WITH FILE = 1, 
 MOVE N'OldDatabaseName' TO N'C:\NewDatabaseName.mdf', 
 MOVE N'OldDatabaseName' TO N'C:\NewDatabaseName_1.ldf', 
 NOUNLOAD, 
 STATS = 10
GO

3: What's this "NOUNLOAD" parameter? I can't find any reference to it in the searching I've done.

asked Jan 29, 2014 at 21:45

1 Answer 1

3
  1. Only if you have applications, T-SQL code, synonyms etc. that reference this database by name. If this is not a production environment, you could test this on the existing copy using ALTER DATABASE ... MODIFY NAME and seeing what breaks, or just taking the current copy of the database OFFLINE to see what kind of things might be depending on it. If this is production, you better take the old copy of the database offline as soon as you restore the copy as a new name, because your apps etc. could still be connecting to the old database and you wouldn't know.
  2. Close, but I think that the second MOVE command should be MOVE N'OldDatabaseName_log'. Of course this will leave the files named with the old database name; you can do more cleanup to modify those files individually if you want it to be squeaky clean (I think this can be overkill except in cases where I have built automation around the assumption that files are named for their container).
  3. NOUNLOAD is not really relevant today, and you can probably leave it out of all RESTORE statements going forward. From the old SQL Server 2000 documentation (the last time it appeared fully documented, IIRC):

Specifies that the tape is not unloaded automatically from the tape drive after a RESTORE. NOUNLOAD remains set until UNLOAD is specified. This option is used only for tape devices. If a non-tape device is being used for RESTORE, this option is ignored.

answered Jan 29, 2014 at 22:09
1
  • Thank you very much. I'm going to test moving the database today and I'll return to mark your answer if it all goes well. Commented Jan 30, 2014 at 13:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.