Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Joseph Schrag
Starting Member
13 Posts |
Posted - 2009-06-22 : 15:13:08
|
| Does anyone know how to script out a complete job definition (job creation script) from a T-SQL query? In SQL Server Managment Studio, you can right click a job and script out a complete definition. I just want to call this same functionality from code rather than the UI. I am using SQL Server 2005. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-22 : 15:55:17
|
You probably can.All information is in the sysjobs and sysjobsteps tables. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Joseph Schrag
Starting Member
13 Posts |
Posted - 2009-06-22 : 16:13:45
|
| Thanks for the reply, Peso. I realize, given enough time, I can probably script all this up by hand. But, I am hoping someone has done this before and has an easier way. |
 |
|
|
Joseph Schrag
Starting Member
13 Posts |
Posted - 2009-06-22 : 18:53:17
|
| I found my solution. I am using the SMO and the Script() method for the job object. Calling that from my client program gives me exactly what I am after.http://www.sqlmonster.com/Uwe/Forum.aspx/sql-server/54161/Can-I-script-out-SQL-Server-jobs-programmatically#gMGdnfSngKyMaKLXnZ2dnUVZ_o2dnZ2dspeakeasynetThanks for your help Peso!! |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2009-06-22 : 19:32:37
|
SMO exposes the Script() method on nearly every object type. it's definitely the way to go if you are already in code. elsasoft.org |
 |
|
|
|
|
|