In my C++ application (with MFC) developed in Visual Studio 2010 the user has an option to take a backup of the current database. This is done by executing a Stored Procedure which takes the database name and backup file name as parameters:
CREATE PROCEDURE sp2_backup_database @DATABASE nvarchar(100), @FILENAME nvarchar(260)
SET NOCOUNT ON
Exec ('Backup Database [' + @DATABASE + '] TO DISK = '' + @FILENAME + ''
WITH COPY_ONLY, NOFORMAT, INIT, NAME = '' + @DATABASE +
'-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10')
All this works fine, the backup is done properly by the SP.
What is bothering me is that when trying to make a restore of the database from the backup file the restore fails with a message like (freely translated from Swedish):
"Restore failed for [the SQL Server]. (Microsoft.SqlServer.SmoExtended)
System.Data.SqlClien.SqlError: RESTORE can not process the database [Database-name] since it's in use by this process. It's recommended to use master database during this task."
The only way I can
View Complete Post