August 22, 2007 at 8:56 am
If you use the Restore option in SSMS and
(e.g. MyStuff.mdf, MyStuff1.ndf, MyStuff2.ndf etc)
then the GUI / Wizard will change the destination for each file to the destination server’s default folder.
If you try to run the restore then you will see the following error
File 'C:\testmssql\data\Sales\MyStuff.mdf' is claimed by ‘MyStuff_0'(3) and ‘MyStuff_DAT'(1). The WITH MOVE clause can be used to relocate one or more files.
Msg 3176, Level 16, State 1, Line 1
If you generate the SQL code from the Restore dialog box, then you will see that it will use the WITH MOVE option correctly, however it will use the same destination file name for each data file.
RESTORE DATABASE [assystv5_FR]
FROM
DISK = N'C:\testmssql\backup\MyStuff_DB.BAK'
WITH
FILE = 1,
MOVE N'MyStuff_DAT'
TO N'C:\testmssql\data\Sales\MyStuff.mdf',
MOVE N'MyStuff_0'
TO N'C:\testmssql\data\Sales\MyStuff.mdf',
etc…
My question : is there an easy way around this, other than generating the TSQL code and modifying the file names manually?
(I’m writing a user guide for doing simple SQL 2005 tasks and it would be good to have a method of doing this that didn’t involve the user having to determine the correct file names, generating the TSQL code and then manually modifying them).
August 22, 2007 at 9:44 am
I've found the cause of the problem.
All of our data files had the file extension '.mdf' (don't blame me, I didn't create the database) Presumably SSMS looks at the extension, assumes (not unreasonably) that there should only be one mdf file and so uses the name of the first mdf file it comes across.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply