Restoring database keep getting error session in use

  • Full error:

    ' RESTORE cannot process database 'SmecIntranet' because it is in use by this session. It is recommended that the master database be used when performing this operation. (Microsoft.SqlServer.Smo) '

    I know it seems obvious enough, session in use, but I ran sp_who2 and there are no processes running against the db I want to restore. I have tried clicking on Master db and restoring from there, but still get same error.

    I also checked the processes in the Activity Monitor part and there is nothing

    I have restored this db once before when I created it and it was OK.

    The backup comes from a SQL2000 server.

    I am a bit green with 2005, am I missing something completely obvious?

     

     

  • This was removed by the editor as SPAM

  • Hello,

    I have had the same problem and don't understand why...

    As bypass, I have deleted the database, recreated it and after that the restore has worked. It is not glorious... but it works...

    Pierre

  • Many Thanks

    I eventually tucked into the SQL query analyser side of it, and started to write a restore script, took a bit of fiddling, but this went thru eventually OK:-

    RESTORE DATABASE SmegIntranet

       FROM DISK = 'C:\SmegIntranet_db_200603220900.BAK'

    WITH NORECOVERY, 

    MOVE 'SmegIntranet_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\SmegIntranet_Data.MDF',

       MOVE 'SmegIntranet_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\SmegIntranet_Log.LDF',

    replace

    GO

    Blimey SQL 2005, takes so much care of itself, almost makes it more difficult to do what you could do easily before.

    Thanks

  • HI,

          I faced the same error message while trying to restore by rewriting an existing database. I solved this by selecting the databse insql server studio and then clicking on make offline which takes the database offline. Select the correct mdf and ldf files and bingo it works !!!

    Regards,

    Sriram

  • If you do not see any active sessions for the database you are trying to restore, it means that this is the default db of the user you logged in as. The db gets locked and you won't be able to restore it.

    To avoid this effect, log in as some other user or change default db to master.

  • I know this is adding to a really old post but that's exactly the message I'm getting, trying to restore a test version of a database from last night's backup of the live version. Both in sqlserver 2005. My default database when I log into the server is tempdb, so any advice gratefully received.

    Cheers, Jules.

  • Please start a new thread for a new question in future.

    There's some connection to the DB that you're trying to restore. Not necessarily yours, but there is one. If you're using management studio, it could be the connection from object explorer.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply