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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Job to Schedule Restore - SQL 7.0 - using TSQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-13 : 08:04:41
Ana writes "I have 2 servers:
one with our production database
the other, Report server has an existing database and needs to be restored every night with a backup of our production database.
The production database backup is local in our Report Server,I created a new job using TSQL and scheduled it, but it fails:

RESTORE DATABASE DATABASENAME FROM DISK='D:\MSSQL7\BACKUP\DATABASENAME.BAK' WITH REPLACE

Can anybody help me out??"

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-06-13 : 08:04:42
It would probably help if you told us the error. Off the top of my head I'd guess that it probably can't get exclusive access to the database.
Go to Top of Page

Arojas
Starting Member

2 Posts

Posted - 2002-06-13 : 10:30:05
The error that I get even when manually starting the job is not really specific:
"The job failed. The job was invoked by user GNC_Web\Administrator. The last step to run was step 1(Restore)"

The database owner=GNC_Web\Administrator

Under Security \ Logins, I have the following information:
-General Tab-
Grant Access
Database:Master
Language: English

-Server Roles Tab-
System Administrator

-Database Access-
Databasename is check on, and Access by=Administrator
Database Roles= Public & db_owner

Hope, this was useful.
Thanks,

Go to Top of Page

Kevin Snow
Posting Yak Master

149 Posts

Posted - 2002-06-13 : 12:03:42
The job may fail if there is a current user in the database. Check the SHOW STEP DETAILS check box, then select the step ID to get a better description of the error. In my test, the job succeeded when run under the MASTER database, but failed when the active database was the same as the one I was restoring (Northwind).

I got:

The job failed. The Job was invoked by User DOE\ksnow. The last step to run was step 1 (First).

and under STEP DETAILS:

Exclusive access could not be obtained because the database is in use. [SQLSTATE 42000] (Error 3101) RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed.

If this isn't the problem, you may need to set the database to DBO ONLY in order to isolate it from users.

I assume you have run the job manually with at least one success?
Go to Top of Page

Arojas
Starting Member

2 Posts

Posted - 2002-06-17 : 09:56:09
Thanks, the job succeeded when I run it under the MASTER database. This job will be on schedule at 4:00am, therefore, I won't have to worry about any users accessing the database at the time the restore is taking place.

Thank you once again.


Go to Top of Page
   

- Advertisement -