Restoring DB in SQL Server executing a query command
I was having a problem trying to restore a DB from a backup with the error message "Error 3154: The backup set holds a backup of a database other than the existing database.". I finally found how to make it executing a manual query instead than trying to use SQL Server menu options. To execute the query you need to open a Query and execute it from Master, not from the db to restore. [sourcecode language="sql" wraplines="false"] ALTER DATABASE MyDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE RESTORE DATABASE MyDatabaseName FROM DISK = 'MyDatabaseName.bak' WITH REPLACE [/sourcecode] The fix consists on using that "WITH REPLACE" sentence. Note: The page where I got the query sets the backup file using "c:/Filename.bak" but my SQL Server was configured to look into C:/Program Files/SQL Server/.../backups/…