Hi, I want to write a SP which takes 3 input parameters job name, Date,and server. Depending on these 3 parameters I want the output like "Job completion Date Time" and "Duration of that job". Any one help me in this. Regards, Pradeep
Run, Use msdb select * from sysjobs and take a look. Luis Martin Moderator SQL-Server-Performance.com Although nature commences with reason and ends in experience it is necessary for us to do the opposite, that is to commence with experience and from this to proceed to investigate the reason. Leonardo Da Vinci Nunca esperes el reconocimiento de tus hijos, eso ocurrirá luego de tu muerte All postings are provided “AS IS†with no warranties for accuracy.
This should get you going<br /><pre id="code"><font face="courier" size="2" id="code"><br />SELECT j.name<br /> , DATEADD(s,h.run_time/10000*3600+h.run_time%10000/6000+h.run_time%100,CAST(h.run_date AS CHAR(<img src='/community/emoticons/emotion-11.gif' alt='8)' />)) <br /> AS Last_Run_Time<br /> , h.run_duration<br /> FROM dbo.sysjobhistory h<br /> JOIN dbo.sysjobs j ON j.job_id = h.job_id<br /></font id="code"></pre id="code"><br /><br />--<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Heute schon gebloggt?<a target="_blank" href=http://www.insidesql.de/blogs>http://www.insidesql.de/blogs</a><br />