October 11, 2006 at 9:08 am
/****** TABLES ******sysjobssysjobstepssysjobserverssysjobschedulessysjobhistorysysalerts
systaskids********************/
ALL Reality is Virtual...
October 11, 2006 at 9:33 am
Roger,
It sounds prefectly feasible but I would suggest stearing clear from writing scripts against your system databases.
Have you investigated the use of the 'SQL Server Agent Procedures' BOL: System Stored Procedures (Transact-SQL Reference)?
You have sprocs such as:
sp_add_job, sp_add_job_step and sp_add_jobschedule.
You could then make a much cleaner solution such as follows:
I can go into more depth if you want to follow that kind of route.
ll
October 11, 2006 at 10:11 am
Thanks, but that seems a little cumbersome when the jobs already exist on the production server and are subject to change from day to day.
What am I missing regarding the relationships and operation of MSDB tables?
ALL Reality is Virtual...
October 12, 2006 at 2:25 am
I wouldn't say cumbersome is the word, I would say maintainable, stable and also upwards compatible if you plan to upgrade to 2005. How long do you want this solution to last? I would really enforce again that you shouldn't be updating/querying the system tables directly, especially when such a thorough set of system stroed procedures are available.
How are you planning to script the jobs out of the Production server? I have done this before when moving to a new serevr and didn't find it a particulalry clean way to create jobs on the target server. I ended up re-scritping the jobs using the system stored procedures and keeping the scripts in source control, that way I can always re-create them if need be on any server by substituting a few variables.
ll
October 12, 2006 at 10:27 am
II,
OK, I'd really prefer to let you convince me.
So, how do I use system stored procedures to script the jobs out of the production server into tables? Even if I could capture the result set from sp_help_job, its columns don't exactly match the parms of sp_add_job, so I'd have to use dynamic SQL to explicitly equate the columns to the parms... and these will undoubetely change in SQL2005.
Here's what I was planning to do (after deleting from the test server)...
______________________________________________
* -- No need to know current column structure
into #jobs_transfer
holst.msdb.dbo.sysjobs -- Test Server
* from #jobs_transfer
jbs
,owner_sid=(select sid
Roger
ALL Reality is Virtual...
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply