If you're absolutely sure you have exclusive access it maybe due to some sort of stupid non intuitive workflow of Management Studio, where you need to put the UI focus on another database that's not the one you are trying to restore. When I think I should have exclusive access it will still tell me I don't. I've had this trouble on some SQL servers as well. Use the above script to see if the database files are being used by a different database. This should enable you to pinpoint the issue.Īs for the error message you are seeing: If the files are in use, then somebody or some system is using them. If the files do exist run the following statement to find out which database is using the files: SELECT DB_NAME(database_id), FILE_ID, physical_name, state_desc FROM sys.master_files However, before you execute the script or finish the dialog by clicking on OK, ensure that the files you listed in the Restore As portion do not exist on the file system. One named 'Original File Name' and an additional 'Restore As' column where you can modify the database file path and file names for the new database.īecause you are restoring a new database, there is no need to specify the WITH_REPLACE option, as the database does not yet exist. Assuming you are using a new database name and you changed the file location then the restore dialog in the Files section will have displayed two (2) columns. MOVE N'StackExchange_log' TO N'E:\SQL\SQL_LOGS\StackExchangeNew_log.ldf', MOVE N'StackExchange' TO N'D:\SQL\SQL_DATA\StackExchangeNew.mdf', SQL Server will move the logical file name to a new file location Here is an example of a script that can be generated when you iterate through your steps and instead of clicking on OK, you click on the generate script icon and send to a new query window: USE įROM DISK = N'F:\SQL\BACKUP\SRV1\StackExchange\FULL\SRV1_StackExchange_FULL_20170624_223003.bak' :Exclusive access could not be obtained because the database is in use. Restore of database 'DELVIPROD_JUNE' failed. (unnecessary on the other computer) Check Close existing connections to destination database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |