﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / last job that ran / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 21:02:02 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: last job that ran</title><link>http://www.sqlservercentral.com/Forums/Topic1384771-1292-1.aspx</link><description>SELECT 	sj.name,	so.name,	max(run_date) [LastRunDate]FROM 	msdb.dbo.sysjobs sj 	inner join msdb.dbo.sysjobhistory sjh 		on sj.job_id  =sjh.job_id	inner join msdb.dbo.sysoperators so 		on sj.notify_email_operator_id = so.idGROUP BY 	sj.name,	so.name</description><pubDate>Tue, 20 Nov 2012 07:11:58 GMT</pubDate><dc:creator>RedDoorSQL</dc:creator></item><item><title>RE: last job that ran</title><link>http://www.sqlservercentral.com/Forums/Topic1384771-1292-1.aspx</link><description>Not sure if I'm late or not but here is one I have used:SELECT        name,                             (SELECT        MAX(run_date) AS MaxRunDate                               FROM            msdb.dbo.sysjobhistory AS B                               WHERE        (job_id = A.job_id)) AS MaxDate,                             (SELECT        MAX(run_time) AS MaxRunTime                               FROM            msdb.dbo.sysjobhistory AS B                               WHERE        (job_id = A.job_id)) AS MaxTimeFROM            msdb.dbo.sysjobs AS AWHERE        (name = 'YourJobName')</description><pubDate>Thu, 15 Nov 2012 10:18:49 GMT</pubDate><dc:creator>kylesway</dc:creator></item><item><title>RE: last job that ran</title><link>http://www.sqlservercentral.com/Forums/Topic1384771-1292-1.aspx</link><description>[quote][b]eugene.pipko (11/15/2012)[/b][hr]Not sure why it doesn't make sense to you.For instance you have a scheduled job that runs at 6PM daily. You have an automated email every morning reporting success/failure.Then job broke. You made corrections and ran it MANUALLY. Now, the next morning you only want to see the report about automated jobs, not the one manual once.That's fine, I found a way to do it. I am looking at highest instance for a given job to pick the latest.[/quote]Remember when posting that others cannot see what you see nor do they know that you have attached special meaning to the word "last" unless you explain it. Your clarification about automated versus manual job executions was excellent. If you had written in your first post what you just wrote in your most recent post you most likely would have received a response within only a few minutes. I am happy you found a path forward!</description><pubDate>Thu, 15 Nov 2012 09:11:23 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: last job that ran</title><link>http://www.sqlservercentral.com/Forums/Topic1384771-1292-1.aspx</link><description>Not sure why it doesn't make sense to you.For instance you have a scheduled job that runs at 6PM daily. You have an automated email every morning reporting success/failure.Then job broke. You made corrections and ran it MANUALLY. Now, the next morning you only want to see the report about automated jobs, not the one manual once.That's fine, I found a way to do it. I am looking at highest instance for a given job to pick the latest.</description><pubDate>Thu, 15 Nov 2012 09:03:21 GMT</pubDate><dc:creator>rightontarget</dc:creator></item><item><title>RE: last job that ran</title><link>http://www.sqlservercentral.com/Forums/Topic1384771-1292-1.aspx</link><description>Huh? If one job executed twice then asking "which one executed last" does not make a lot of sense since it is the same job that executed both times.For detailed info about jobs and job history you can look in the tables in the dbo schema in msdb with the prefix [i]sysjob[/i].</description><pubDate>Thu, 15 Nov 2012 06:44:17 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>last job that ran</title><link>http://www.sqlservercentral.com/Forums/Topic1384771-1292-1.aspx</link><description>Hi all,If I have a job that executed twice, how can I, using t-sql, find which one executed last?Thanks,Eugene</description><pubDate>Wed, 14 Nov 2012 10:51:41 GMT</pubDate><dc:creator>rightontarget</dc:creator></item></channel></rss>