Jun 30, 2003 #1 TheJFM Programmer Jun 13, 2002 65 GB As part of routine maintenance I script all jobs through Enterprise manager. Is there a way of calling the procedure that scripts all jobs in order to make this a regular task? ** Don't reach for the moon when you have the stars. ;-) TheJFM **
As part of routine maintenance I script all jobs through Enterprise manager. Is there a way of calling the procedure that scripts all jobs in order to make this a regular task? ** Don't reach for the moon when you have the stars. ;-) TheJFM **
Jun 30, 2003 #2 JayKusch MIS Oct 30, 2001 3,199 US 1. Create a job; ActiveX Script. 2. Paste the code; change the server/path to your desired values. Dim conServer Dim fso Dim iFile Dim oJB Dim strJob Dim strFilename Const ioModeAppend = 8 Set conServer = CreateObject("SQLDMO.SQLServer" conServer.LoginSecure = True conServer.Connect "<servername>" strFilename = "<path where output file will be placed>_JOBS.sql" For Each oJB In conServer.JobServer.Jobs strJob = strJob & "--------------------------------------------------" & vbCrLf strJob = strJob & "-- SCRIPTING JOB: " & oJB.Name & vbCrLf strJob = strJob & "--------------------------------------------------" & vbCrLf strJob = strJob & oJB.Script() & vbCrLf Next Set conServer = Nothing Set fso = CreateObject("Scripting.FileSystemObject" Set iFile = fso.CreateTextFile(strFilename, True) iFile.Write (strJob) iFile.Close Set fso = Nothing Thanks J. Kusch Upvote 0 Downvote
1. Create a job; ActiveX Script. 2. Paste the code; change the server/path to your desired values. Dim conServer Dim fso Dim iFile Dim oJB Dim strJob Dim strFilename Const ioModeAppend = 8 Set conServer = CreateObject("SQLDMO.SQLServer" conServer.LoginSecure = True conServer.Connect "<servername>" strFilename = "<path where output file will be placed>_JOBS.sql" For Each oJB In conServer.JobServer.Jobs strJob = strJob & "--------------------------------------------------" & vbCrLf strJob = strJob & "-- SCRIPTING JOB: " & oJB.Name & vbCrLf strJob = strJob & "--------------------------------------------------" & vbCrLf strJob = strJob & oJB.Script() & vbCrLf Next Set conServer = Nothing Set fso = CreateObject("Scripting.FileSystemObject" Set iFile = fso.CreateTextFile(strFilename, True) iFile.Write (strJob) iFile.Close Set fso = Nothing Thanks J. Kusch