i have this OCX that runs inside of our biling system that allows users to choose jobs and billing periods to run. by choosing a billing period, i then need to relate the billing period info to the job. so i use DMO and basically have a template job that sits out there and never gets run but serves as a template for creating these dynamic jobs. so after i have the billing period and job, i read the job script into a string and replace my variable (@billrunid) inside of the job. now i take this string and execute it but change the job name to the old job name followed by the variable that i passed in, thus creating a new job with a unique name. also keep in mind i set the template job that created this job to have the delete upon completion flag set. so after creating the new job i then start the job, which runs and deletes itself. well, sql server has no way of keeping job histories for deleted jobs so this is where my orginal question came from. i need a way to pull the history prior to the job being deleted which happens upon completion. simply adding the folling between the ---*** to the sp_delete_job sp will resolve the problem:
IF (@delete_history = 1)
---***
insert into comx_kt.dbo.clext_ihwy_jobexecutor_sqljobhistory
select *
from msdb.dbo.sysjobhistory
WHERE job_id IN (SELECT job_id FROM #temp_jobs_to_delete)
----***
DELETE FROM msdb.dbo.sysjobhistory
WHERE job_id IN (SELECT job_id FROM #temp_jobs_to_delete)
so basically modifying the system stored proc seems like the only way to accomplish this task. i just need to know if modifying system stored proc is possible and if so, how...?
thanks for the help