Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 209 Vote(s) - 3.42 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL-Server: Error - Exclusive access could not be obtained because the database is in use

#11
Solution 1 : Re-start SQL services and try to restore DB
Solution 2 : Re-start system / server and try to restore DB
Solution 3 : Take back of current DB, Delete the current/destination DB and try to restore DB.
Reply

#12
Setting the DB to single-user mode didn't work for me, but taking it offline, and then bringing it back online did work. It's in the right-click menu of the DB, under Tasks.

Be sure to check the 'Drop All Active Connections' option in the dialog.
Reply

#13
1. Set the path to restore the file.
2. Click "Options" on the left hand side.
3. Uncheck "Take tail-log backup before restoring"
3. Tick the check box - "Close existing connections to destination database".
[![enter image description here][1]][1]
4. Click OK.


[1]:
Reply

#14
taking original db to offline worked for me

[![take offline][1]][1]


[1]:
Reply

#15
I experienced this issue when trying to restore a database on MS SQL Server 2012.

**Here's what worked for me**:

I had to first run the `RESTORE FILELISTONLY` command below on the backup file to list the logical file names:

RESTORE FILELISTONLY
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\my_db_backup.bak'

This displayed the **LogicalName** and the corresponding **PhysicalName** of the Data and Log files for the database respectively:

LogicalName PhysicalName
com.my_db C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\com.my_db.mdf
com.my_db_log C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\com.my_db_log.ldf

All I had to do was to simply replace the **LogicalName** and the corresponding **PhysicalName** of the Data and Log files for the database respectively in my database restore script:

USE master;
GO

ALTER DATABASE my_db SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO


RESTORE DATABASE my_db
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\my_db_backup.bak'
WITH REPLACE,
MOVE 'com.my_db' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\com.my_db.mdf',
MOVE 'com.my_db_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\com.my_db_log.ldf'
GO

ALTER DATABASE my_db SET MULTI_USER;
GO

And the Database Restore task ran successfully:

That's all.

**I hope this helps**
Reply

#16
I got this error when unbeknownst to me, someone else was connected to the database in another SSMS session. After I signed them out the restore completed successfully.
Reply

#17
Vinu M Shankar's [solution][1] worked for me.

But I had to check the: ***"Take tail-log backup before restoring"*** checkbox for mine to work.



[1]:

[To see links please register here]

Reply

#18
In my case although i tried all of the above solutions, the thing that worked, was to restart SSMS.
Reply

#19
I hope you don't mind the data inside the database you wish to recover. If so; under the Options

- Go to Restore Options
- Choose RESTORE WITH NORECOVERY option under
Recovery State
- Click OK

The above worked for me.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through