Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Restoring db with multiple ndf''s using SSMS Express Expand / Collapse
Author
Message
Posted Wednesday, August 22, 2007 8:56 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 19, 2007 7:10 AM
Points: 17, Visits: 6

If you use the Restore option in SSMS and

 

  • The database has more than one data file
    (e.g. MyStuff.mdf, MyStuff1.ndf, MyStuff2.ndf etc)

  • The default location for the SQL server differs from that of the source server (e.g. C: instead of D

 

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).

Post #392830
Posted Wednesday, August 22, 2007 9:44 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 19, 2007 7:10 AM
Points: 17, Visits: 6

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.

 

Post #392860
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse