Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Restore Database Use Tranction Log File

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2008-06-27 : 02:07:32
hi
i have restore database in sql2005 to use tranction log file.the database single or read only mode. i am use following command to restore Log
RESTORE LOG database
FROM DISK ='H:\LogFile\database_20080626200001.TRN'
WITH NORECOVERY


but i have following error message

Msg 3102, Level 16, State 1, Line 1
RESTORE cannot process database 'database' use 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.

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-06-27 : 02:23:09
Is the query window that you are using to run that restore connected to the database that you are trying to restore?

If so, change your active database to master, as the error message says.

--
Gail Shaw
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2008-06-27 : 02:40:14
thanks for replay

so please tell me how can i do this
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-06-27 : 04:04:07
USE master
GO
RESTORE LOG database
FROM DISK ='H:\LogFile\database_20080626200001.TRN'
WITH NORECOVERY

Or you can use the drop down box at the top of the query window (assuming you're using query analyser or management studio) to change your current database context.

--
Gail Shaw
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2008-06-27 : 04:49:04
yes i use this but i have following error

Msg 3117, Level 16, State 1, Line 1
The log or differential backup cannot be restored because no files are ready to rollforward.
Msg 3013, Level 16, State 1, Line 1
RESTORE LOG is terminating abnormally.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-06-27 : 04:51:15
If your database is online, you cannot restore transaction log backups. It has to be wither in standby mode or nonrecovery.

What are you trying to do?

--
Gail Shaw
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2008-06-27 : 06:04:54
the database is single user.
i am trying to norecovery
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-06-27 : 08:13:11
Did you break log chain?
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-06-27 : 12:14:12
If the database is currently in a read-write state and you want to get it into norecovery, run
BACKUP LOG TO DISK = "File name here" WITH NORECOVERY

However you will not be able to restore previous transaction log backups. The LSNs won't match.

Maybe explain a little more what you have done up until now, what you are trying to do now and what you are trying to achieve

--
Gail Shaw
Go to Top of Page
   

- Advertisement -