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
 Transact-SQL (2000)
 Restore using 'sp_add_jobschedule' (T-SQL)

Author  Topic 

Maria
Starting Member

12 Posts

Posted - 2001-11-23 : 10:04:31
Hello,

I am trying to schedule a complete database restore using TSQL (as Ent.
Manager doesn't offer this functionality). my logic tells me: create a
restore job like so:

RESTORE DATABASE DOGSTraining
FROM DISK = 'd:\mssql7\Ad-hoc Backup\DOGSTraining\DOGSTrainingNov.BAK'

Then create a job shedule using this syntax from BOL:

USE msdb
EXEC sp_add_jobschedule @job_name = 'NightlyRestore',
@name = 'ScheduledRestore',
@freq_type = 4, -- daily
@freq_interval = 1,
@active_start_time = '1:00:00'

I'm assuming that @jobname is meant to the first statement,i.e. the
RESTORE DATABASE job I created above? if this is the case, how do i name
this RESTORE DATABASE job so that i can call it in the
'sp_add_jobschedule' statement? Do i have to use sp_addumpdevice
somewhere along the line?(although i thought this stored procedure was
only for backups...).

All help is fully appreciated!

Kind rgds,

Maria

Maria Bermudes
DBA
London

nr
SQLTeam MVY

12543 Posts

Posted - 2001-11-25 : 20:46:40
A scheduled job has several parts.

job
job steps
jobs schedules

the job steps are what are actually run.
the job schedules will say when the job is to be actioned and which job step is to be run.
the job step will include actions to be taken on succesful/fileure completion - like complete with success/start next job, ....

In your case you need to create a job named 'NightlyRestore'.
Add a jobstep - which will include the restore command.
Add a job schedule to activate the step.
These will all reference the job.


==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -