Blog Post

Taking Script of Sql Server Jobs for Migration

,

when migration sql server database to a new server, i use the following powershell script to take all sql server jobs at one time.

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") 
 
$server = New-Object Microsoft.SqlServer.Management.Smo.Server("localhost")  
$scripter = New-Object Microsoft.SqlServer.Management.Smo.Scripter($server)
$jobs = $server.JobServer.get_Jobs() | Where-Object {$_.Name -notlike "sys*"}     
$script = ""
foreach($job in $jobs){ $script += $job.Script() + "GO`n" }
$script >> "c:\sqljobs.sql"

i will publish all scripts (powershell or sql) that i used when moving database to a new sql server

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating