Showing posts with label active DBCC replicas. Show all posts
Showing posts with label active DBCC replicas. Show all posts

Wednesday, 20 September 2017

Msg 5094, The operation cannot be performed on a database with database snapshots or active DBCC replicas


Error:
Msg 5094, Level 16, State 2, Line 2
The operation cannot be performed on a database with database snapshots or active DBCC replicas.

Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally, .

This error basically comes when there is Snapshot file present for same DB, solution for this is very simple, go to the data file location Eg. C:\MSSQL\DATA\ or wherever you have stored your data files. and Delete YourDatabase.SS file.

Then you can restore your database .

Database restore Command as shown below.


sp_helpdb MY_DATABASE
--to see Logical file name of Data and Log file and location


ALTER DATABASE [MY_DATABASE] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
-- Take your database on Single user for safe side.


RESTORE DATABASE [MY_DATABASE]
FROM DISK = 'D:\PROD Backup\MY_DATABASE.bak'
WITH
MOVE 'MyDatabase_Datafile' TO 'D:\MSSQL\DATA\MY_DATABASE.mdf',
MOVE 'MyDatabase_Logfile' TO 'D:\MSSQL\LOG\MY_DATABASE_log.ldf'


ALTER DATABASE [MY_DATABASE] SET MULTI_USER
-- Back to multi user