Sql-server – How to script SQL Server Jobs for migration

migrationscriptingsql server

When migrating servers, how can I easily script all my SQL Server Jobs onto a new machine?

NOTE

Not accepting "backup msdb" as the answer.

Best Answer

In SQL Management Studio:

  • Click on the jobs folder in Object Explorer
  • Display the Object Explorer Details window (under View menu)
  • Select all or some of your jobs
  • Right-click, script job as Create To New Query Window
  • Change the connection of your query window to the new server
  • Execute the generated script(s)

There you go!

Note: this is for SQL 2005+. SQL 2000 Enterprise Manager has an option to Generate Scripts on the Job Agent, I believe.