Oh, I'm not confused... you are... which is fine, it can be a bit screwball. Inside the bak file there are copies of the ldf and mdf files... THOSE are what will be moved....
here's a segment of a restore I use.
The MOVE command moves the DB_* files in the backup to the location as specified in the second part of the TO .... so the DB_PRIM in the backup gets moved to the D:\Databases\MyDatabase\DATA\DB_PRIM.mdf location. where D:\Databases\MyDatabase\DATA\ points to my NEW EMPTY database.Code:RESTORE DATABASE [myDataBase] FROM DISK = N'D:\Databases\TempStorage\PrimaryDatabase20120501.bak' WITH FILE = 1, MOVE N'DB_PRIM' TO N'D:\Databases\MyDatabase\DATA\DB_PRIM.mdf', MOVE N'DB_DEF1' TO N'D:\Databases\MyDatabase\DATA\DB_DEF1.ndf', MOVE N'DB_DEF2' TO N'D:\Databases\MyDatabase\DATA\DB_DEF2.ndf', MOVE N'DB_DEF3' TO N'D:\Databases\MyDatabase\DATA\DB_DEF3.ndf', MOVE N'DB_DEF4' TO N'D:\Databases\MyDatabase\DATA\DB_DEF4.ndf', MOVE N'DB_IDX1' TO N'D:\Databases\MyDatabase\DATA\DB_IDX1.ndf',
If you don't use the MOVE command it will try to overwrite the files at their original location. That's not what you want.
-tg




Reply With Quote