Restore Tranction Log File in SQL2005

  • hi

    i have restore the database use TRAN Log file in sql2005 in following command

    RESTORE LOG databasename

    FROM DISK ='H:\LogFile\databasename_20080626070001.TRN'

    WITH RECOVERY

    the database is single user mode

    but i have following error

    Msg 3102, Level 16, State 1, Line 1

    RESTORE cannot process database 'database name' because it is in use by this session. It is recommended that the master database be used when performing this operation.

    Msg 3013, Level 16, State 1, Line 1

    RESTORE LOG is terminating abnormally.

  • Have you tried using the master database.

    Basically the restore is failing because you have a connection to the db, if you run the script under the contect ofmast this remove this problem.

    Gethyn Elliswww.gethynellis.com

  • Ellis is right (of course 😉 ).

    SQL will abort a backup if anyone is connected other than the Service. Set your Database Context to Master and try the operation again.

    Regards, Irish 

Viewing 3 posts - 1 through 2 (of 2 total)

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