Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Script all jobs on SQL 2005/2008 Server


Script all jobs on SQL 2005/2008 Server

Author
Message
Roust_m
Roust_m
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1068 Visits: 1953
Hi,

I need to automate scripting of all jobs on a SQL 2005/2008 server. I can't use any Integration Services packages, and apparently SCPTXFR.EXE is no longer present in SQL Server 2005.

Just wondering if there is an existing script for this task, so I could put it as a job step?

Thanks.



yzhu117
yzhu117
SSC Journeyman
SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)

Group: General Forum Members
Points: 80 Visits: 90
In sql server 2005, you can use sql management studio --> select the Job folder in object explore --> select all jobs in object explore details window--> right click and script all the jobs. Some modifications may need if you want to deploy in another computer. Hope it helps.
Roust_m
Roust_m
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1068 Visits: 1953
No, this is not what I want. I don't want a manual process, I want automatic. E.g. a job running every night and scripting all the jobs into a text file.



MG-148046
MG-148046
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2161 Visits: 2692
you can use one of the dot net languages with SMO to script the jobs. This is a snippet from something I did in VB.Net. Please keep in mind that I am not very good with VB. Of course you will need to create all your variable, objects, streamwriter, etc.

There are quite a lot of examples on the net. It's the only way I could do it since I'm not a dot net person.


wf.WriteLine()
wf.WriteLine("-- **** Create Jobs")
wf.WriteLine()

Dim jb As Agent.Job
For Each jb In svr.JobServer.Jobs
smoObjects = New Urn(0) {}
smoObjects(0) = jb.Urn
scrp.Options.IncludeIfNotExists = True
Dim sc As StringCollection
sc = scrp.Script(smoObjects)
Dim st As String
For Each st In sc
wf.WriteLine(st)
wf.Flush()
Next
Next

MG

"There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
Tony Hoare

"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
Roust_m
Roust_m
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1068 Visits: 1953
I am not good with VB either. In fact I have no knowledge of it at all, because I am not a developer. I was just wondering if there is a TSQL script already developed, so I don't have to develop it myself.



MG-148046
MG-148046
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2161 Visits: 2692
The snippet is part of a much larger program that scripts out every object in a database so it would be hard to break down.

Maybe someone who is good with Powershell can help. From some of the PS code I've seen, using the PS SQL provider, someone can probably do this as a PS script.

MG

"There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
Tony Hoare

"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
Rudy Panigas
Rudy Panigas
SSC-Addicted
SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)

Group: General Forum Members
Points: 440 Visits: 1303
Hello everyone,

I believe this will make everyone happy and there is not coding involved. Just search for SQLScripter. A gentleman has create a neat application to script out everything or just some things including jobs. Just modify the confiig file and execute.

That's it.

Rudy



george sibbald
george sibbald
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6334 Visits: 13687
Rudy Panigas (3/11/2009)
Hello everyone,

I believe this will make everyone happy and there is not coding involved. Just search for SQLScripter. A gentleman has create a neat application to script out everything or just some things including jobs. Just modify the confiig file and execute.

That's it.

Rudy


can you provide a URL, search on sqlscripter produced nothing obvious

---------------------------------------------------------------------
Rudy Panigas
Rudy Panigas
SSC-Addicted
SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)

Group: General Forum Members
Points: 440 Visits: 1303
I just Googled it. http://www.sqlscripter.com/



Simon D Richards
Simon D Richards
SSC-Enthusiastic
SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)

Group: General Forum Members
Points: 190 Visits: 639
Hi, I use the following as an active x script from a job on SQL 2000:

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 "##Server_Name##"

strFilename = "C:\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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search