SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Restore


Restore

Author
Message
Joseph DeGaetani
Joseph DeGaetani
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 28
I'm trying to restore a backup from a 'dev' database to copy 'test' database & I'm getting:getting:
'DEV_Database_Test.mdf' cannot be overwritten. It is being used by database 'DEV_Database_Test'
&
File 'DEV_Data' cannot be restored to 'C:\MSSQL\DATA\DEV_Data_Test.mdf'. Use WITH MOVE to identify a valid location for the file.
File 'DEV_Data_2' cannot be restored to 'C:\MSSQL\DATA\DEV_Data_Test_2.ndf'. Use WITH MOVE to identify a valid location for the file.
File 'DEV_Data_Log' cannot be restored to 'C:\MSSQL\DATA\DEV_Data_Test_Log.ldf'. Use WITH MOVE to identify a valid location for the file.

Even when I'm setting the database offline & using MOVE...
Here's my syntax:
USE [master]
ALTER DATABASE Dev_Database_Test
SET OFFLINE WITH ROLLBACK IMMEDIATE
GORESTORE DATABASE Dev_Database_Test
FROM DISK='C:\MSSQL\Backup\DEV-database'+ (select CONVERT(VARCHAR(8), getdate(), 112))+'.bak'
WITH
MOVE 'DEV-Database_Data' TO 'C:\MSSQL\DATA\Dev_Database_Test.mdf',
MOVE 'DEV-Database_1_Data' TO 'C:\MSSQL\DATA\Dev_Database_Test_1.ndf',
MOVE 'DEV-Database_Log' TO 'C:\MSSQL\DATA\Dev_Database_Test.ldf'
ALTER DATABASE Dev_Database_Test SET ONLINE
GO
ALTER DATABASE Dev_Database_Test SET MULTI_USER
GO

Any help would be greatly appreciated
Matt Crowley
Matt Crowley
SSC-Addicted
SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)

Group: General Forum Members
Points: 435 Visits: 469
If you are trying to overwrite the existing dev database, you will need to add REPLACE to your with list.
Joseph DeGaetani
Joseph DeGaetani
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 28
Even when I'm setting the database offline, WITH REPLACE & MOVE... I'm getting the same error...
Here's my syntax:
USE [master]
ALTER DATABASE Dev_Database_Test
SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
RESTORE DATABASE Dev_Database_Test
FROM DISK='C:\MSSQL\Backup\DEV-database'+ (select CONVERT(VARCHAR(8), getdate(), 112))+'.bak'
WITH REPLACE,
MOVE 'DEV-Database_Data' TO 'C:\MSSQL\DATA\Dev_Database_Test.mdf',
MOVE 'DEV-Database_1_Data' TO 'C:\MSSQL\DATA\Dev_Database_Test_1.ndf',
MOVE 'DEV-Database_Log' TO 'C:\MSSQL\DATA\Dev_Database_Test.ldf'
ALTER DATABASE Dev_Database_Test SET ONLINE
GO
ALTER DATABASE Dev_Database_Test SET MULTI_USER
GO
Matt Crowley
Matt Crowley
SSC-Addicted
SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)SSC-Addicted (435 reputation)

Group: General Forum Members
Points: 435 Visits: 469
OK, how about we have a look at what is really going on with the files in both places. Run these, and post the results:
restore filelistonly from disk ='C:\MSSQL\Backup\DEV-database'+ (select CONVERT(VARCHAR(8), getdate(), 112))+'.bak'

select name, physical_name
from Dev_Database_Test.sys.database_files



You may want to run the second query on the source database, as well, just to see if someone added a fourth file on you.
Joseph DeGaetani
Joseph DeGaetani
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 28
The names no longer protect the innocent, but who really cares...Thanks

DEV-Dysel_Data c:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEV-Dysel_Data.mdf D PRIMARY
DEV-Dysel_1_Data c:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEV-Dysel_1_Data.ndf D Data Filegroup 1
DEV-Dysel_Log c:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEV-Dysel_Log.ldf L NULL

select name, physical_name from Dev_Dysel_Copy.sys.database_files =
DEV-Dysel_Data C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEV_Dysel_Copy_Data.mdf
DEV-Dysel_Log C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEV_Dysel_Copy_Log.ldf
DEV-Dysel_1_Data C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEV_Dysel_Copy_1_Data.ndf
Joseph DeGaetani
Joseph DeGaetani
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 28
Thanks you for the help grasshopper. I had the same logical files names for both databases.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search