Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / July 2008

Tip: Looking for answers? Try searching our database.

error "the file mydb.mdf cant' be overwritten ..."

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mich - 07 Jul 2008 14:19 GMT
Hi,

i made a database 'mydb' in sql server 2005 express and a backup of it
'mydb.bak'.
I changed some tables, indexes etc ... in the database and made a new backup
of this new version of 'mydb' but before that, i changed the previous backup
'mydb.bak' into 'maydboldversion.bak'.
So i have now two backup's: 'mydb.bak' and 'myddolsversion.bak'.

Now i want to restore the oldversion, but keeping the new one. When i try to
restore it, i get the error "the file mydb.mdf cant' be overwritten ..".

How can i restore the oldversion database?
Thanks
Mich
Russell Fields - 07 Jul 2008 16:48 GMT
Mich,

At the risk of sounding insulting (which I am not trying to be), how did you
backup the database?

a. From SQL Server: BACKUP DATABASE mydb TO DISK = mydb.bak
b. From Windows: Copy mydb.mdf mydb.bak

If you did a, then how are you trying to restore?  Are you using RESTORE
DATABASE?

"The file mydb.mdf can't be overwritten..." sounds like an operating system
copy file onto an open file.  If so, you definitely do not want to be doing
this.

If you give a little more detail, actual commands, it may be more clear what
happened.

RLF

> Hi,
>
[quoted text clipped - 12 lines]
> Thanks
> Mich
Ekrem Önsoy - 07 Jul 2008 18:29 GMT
I think it raises that error because you are trying to overwrite (by
restoring \ extracting database files) to the current ones which are already
attached to your SQL Server instance. And as it can't overwrite to the
current ones, it raises this error.

If you are performing this action using SSMSE, then ensure that you change
the path of the files to be extracted from the backup file to another path
or change the file names of the database files so that it'll not try to
overwrite to the current ones. If you are intended to overwrite them, then
ensure you checked "Overwrite the existing database" checkbox in the Restore
Options pane of the Restore Database window in SSMSE.

Signature

Ekrem Önsoy

> Hi,
>
[quoted text clipped - 12 lines]
> Thanks
> Mich
Mich - 07 Jul 2008 21:20 GMT
Thanks for reply,

First, i created database 'mydb'.
Then i made a backup 'mydb.bak' with SSMSE (i put in c:\backup).
In c:\program fies\sql server\mssql\..\data, there is now file 'mydb.mdf'
Then i changed a lot of thinks to 'mydb' in Studio Management.
Then i changed in c:\backup the file mydb.bak to mydboldversion.bak.
Then i made a backup 'mydb.bak' of the modified 'mydb' database in
c:\backup.

In c:\backup, there are now 'mydb.bak' and 'mydboldversion.bak'.

What i want is to restore the database before it was modified, using
'mydboldversion.bak' and doing it into Studio Management.

The problem is that both .bak files are linked to 'mydb.mdf' in c:\\program
files\sql server\mssql\...\data

>I think it raises that error because you are trying to overwrite (by
>restoring \ extracting database files) to the current ones which are
[quoted text clipped - 24 lines]
>> Thanks
>> Mich
Uri Dimant - 08 Jul 2008 08:44 GMT
Mich
Is there REPLACE option to overwrite the database?

> Thanks for reply,
>
[quoted text clipped - 43 lines]
>>> Thanks
>>> Mich
Ekrem Önsoy - 08 Jul 2008 09:20 GMT
You can use the WITH REPLACE keyword as Urin mentioned, or you can delete
your database from SSMSE' s object explorer and then restore the database
from your backup file. (Of course ensure that your backup file works in case
you decide to delete your database)

As your database' s files (mdf and ldf in your case) will be deleted when
your database is deleted from SSMSE, your backup will be restored without an
overwrite problem.

Signature

Ekrem Önsoy

> Thanks for reply,
>
[quoted text clipped - 43 lines]
>>> Thanks
>>> Mich
Mich - 08 Jul 2008 09:49 GMT
Thanks to all, it works now.

> You can use the WITH REPLACE keyword as Urin mentioned, or you can delete
> your database from SSMSE' s object explorer and then restore the database
[quoted text clipped - 52 lines]
>>>> Thanks
>>>> Mich
Ekrem Önsoy - 08 Jul 2008 12:03 GMT
Note:
I'm sorry Uri, I wrote your name as "Urin" in my previous post by mistake.

Signature

Ekrem Önsoy

> Thanks to all, it works now.
>
[quoted text clipped - 55 lines]
>>>>> Thanks
>>>>> Mich
Uri Dimant - 08 Jul 2008 12:24 GMT
Its OK :-)

> Note:
> I'm sorry Uri, I wrote your name as "Urin" in my previous post by mistake.
[quoted text clipped - 58 lines]
>>>>>> Thanks
>>>>>> Mich
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.