Search code examples
t-sqlsql-server-2008-r2jobsdatabase-backupsjob-scheduling

Include a job in the database backup, to be activated when the backup is restored


When I take a backup of a database (SQL Server), is there any way that I can include a scheduled job in the backup?

I have a database with stored procedures and a maintenance job that runs some of the stored procedures nightly.

I would like to achieve a minimal effort to schedule the job, when the .bak file is restored into a server, back as a database.


Solution

  • I don't have the quick button to click for your problem, but I think (not sitting in front of it right now) You can right click a job and get a script for its creation including scheduling specifics. I don't know how to include a job in a backup and how to restore it, though. I think restoring a job would require a script with the CREATE for the job to be run.