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?

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.

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

Please mark this thread as solved if you have found a solution to your problem and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.