Friday, February 24, 2012

Help me to restore this database!!!

Hi,
I have a database named 'ePos' and i want to make
a copy from it by backup this database then restore
it as a new one with another name.
I use this commands:

sp_addumpdevice 'disk',
'ePosTest1',
'c:\test1.bak'

BACKUP DATABASE ePos TO ePosTest1 WITH INIT
GO

RESTORE DATABASE ePos_new FROM ePosTest1
GO

I have this error when restoring :
Server: Msg 1834, Level 16, State 1, Line 7
The file 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\ePos2006.mdf' cannot be overwritten. It is being used by database 'ePos2006'.

How can i restore the database with new filesys? how i can fix this problem?

PLZ help.

Regards.

For best results, try posting this in a different forum more related to your issue. At the top of the screen, you will see the forum hierarchy. (MSDN Forums >> SQL Server >> SQL Server Integration Services...) Click on the SQL Server part of that tree to see the full list of forums related to SQL Server.

I'd suggest trying the disaster recovery forums.|||This thread was originally posted in SSIS forum...moved to Disaster Recovery and Availability|||

By default, SQL backups are restored to the same path as the original database.

In your case, you want to have the same content in different files, so you'll need to use the WITH MOVE clause:

RESTORE DATABASE ePosNew FROM ePosTest1

WITH MOVE 'ePos2006' TO 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\ePosNew.mdf' ,

MOVE 'ePos2006_log' TO 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\ePosNew_log.ldf'

go

You'll have to verify the logical names of your data and log files, but this is the technique.

No comments:

Post a Comment