Sunday, June 22, 2008

RESTORE cannot process database because it is in use by this session

"System.Data.SqlClient.SqlError: RESTORE cannot process database because it is
in use by this session. It is recommended that the master database be used
when performing this operation."

If you are using Microsoft.SqlServer.SMO set SqlServer.ConnectionContext.DatabaseName to "master".
If you are using TSQL, select master database (USE master).

Keys: error, smo, tsql, c#.

3 comments:

Anonymous said...

If you're still experiencing problems, try to restart the service.

Unknown said...

Recover corrupt SQL database and easily get restore on SQL Server by utlizing SQL recovery tool. Get more information http://www.sqlrepairtool.org

Unknown said...

Use SQL Database Repair application which can retrieve MDF and NDF file from SQL server database. This application is compatible with all SQL version such as 2012, 2008R2, 2008, 2005 & 2000. Get more detail: http://www.filesrecoverytool.com/sql-database-repair.html