SQL Server 2005 Restore problem session in use

  • I need to restore a SQL Server as a user has run a Find and Replace on data in a table and altered data incorrectly. When I run the Transaction Log Back Up or the Restore Database I receive the message:

    System.Data.SqlClient.SQLError: RESTORE cannot process database because it is in use by this session.

    I have restored other test databases on the Server with no problem. Any ideas what the problem might be.

    The only difference I can find is the Owner of the test databases is Administrator while I am the Owner of the database which wont restore, and I have logged in as myself.

    Hope someone might be able to help.

  • the login access u hav in the server is to this DB alone or it is the default DB marked..

    In both the cases the above error is possible and ofcourse it is just one of the possibilities...

    in the primary case nothing can be done, but if u hav access to multiple DBs u can change the default DB to some other DB n try ...

  • When you are running the restore command - you are also accessing the database. Change the database context to a different database and reissue the command.

    Jeffrey Williams
    Problems are opportunities brilliantly disguised as insurmountable obstacles.

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Thanks for that, I can now login by changing the Database to open for example to Master or one of my test databases.

    Unfortunately I now seem to be in a Catch22 situation as I previously took a database offline which would appear to be the default database, and when requesting it to be brought back on line or checking properties etc I receive a message that the default database is not available i.e. Failed to connect to Server..Cannot open user default database..Login failed for Administrator.

    Any ideas how I can get around this. Tried attaching a copy of the mdf and ldf files but receive the same message as above.

    Many thanks for any help you might be able give. e.g. how can I change the default db for a user.

    Took the database offline as the Administrator

  • To All

    Now got db back on line using Alter Login UserName WITH DEFAULT DATABASE = XXXXX statement etc statement.

    Many thanks for assisrtance much appreciated

Viewing 5 posts - 1 through 4 (of 4 total)

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