WARDY IT Solutions Blog

A blog on Brisbane's leading SQL Server consulting and training company

SQLDMO Script SQL Server Jobs

The following VBScript code snippet can be used to script all SQL Server Jobs on a SQL Server instance:

~~

Const ForWriting = 2

Dim job
Dim oFSO
Dim oFSOWrite
Dim oSQLServer

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oSQLServer = CreateObject("SQLDMO.SQLServer")

oSQLServer.LoginSecure = True
oSQLServer.Connect "(local)"

Set oFSOWrite = oFSO.OpenTextFile("c:\sqljobs.sql", ForWriting, True)

For Each job in oSQLServer.JobServer.Jobs
 oFSOWrite.WriteLine job.script
Next

oFSOWrite.Close

Set oFSO = Nothing

~~

Published Tuesday, December 20, 2005 3:25 PM by peter@wardyit.com

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit