0

Hi there!

I made a backup of my database (MandoTECA) using the following code:

CREATE PROCEDURE [dbo].[CreateBackup]
@uri nvarchar(MAX)
AS
BACKUP DATABASE MandoTECA
--TO DISK = 'C:\Users\Pedro\Desktop\MandoTECA.Bak'
TO DISK = @uri
   WITH FORMAT,
      MEDIANAME = 'Z_SQLServerBackups',
      NAME = 'Backup Completo da MandoTECA';

And used it a restore procedure to do the restore:

CREATE PROCEDURE [dbo].[RestoreBackup]
@uri nvarchar(MAX)
AS

RESTORE DATABASE MandoTECA
FROM DISK = @uri

The problem is that it gives me the following error:

[img]http://img197.imageshack.us/img197/518/errormmp.jpg[/img]

Can you help me?

2
Contributors
3
Replies
5
Views
8 Years
Discussion Span
Last Post by sknake
0

The problem is the procedure you are trying to use CREATE PROCEDURE [dbo].[CreateBackup] exists inside the database you are trying to restore. For a database to be restored nobody can be using it. You need to use the "master" database when issuing a restore command and you should sent it the query to restore. I do not recommend creating a restore SP in the master database.

0

Its exactly that.

I created in the master Database and worked just fine.

In my application i have another connectionString to the Master Database just to call the restore Stored Procedure.

Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.