SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

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.

$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


Posted by Anonymous on 23 June 2011

Pingback from  ??pucu #12 – Script SQL Server Jobs (PowerShell)            -sedat salman

Posted by Jason Brimhall on 23 June 2011

Nice - that could prove useful.

Posted by Anonymous on 26 June 2011

Pingback from  learnSQL.99hosting.info  » Blog Archive   » Taking Script of Sql Server Jobs for Migration – SQL Server Tips …

Posted by Anonymous on 18 September 2011

Pingback from  SQL Job Migration(powershall script) « Simon's SQL

Posted by bm0072424 on 4 November 2011


Leave a Comment

Please register or log in to leave a comment.