<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Find Next Running Time of Scheduled Job Using T-SQL</title>
	<atom:link href="http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 10 Feb 2012 02:12:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Dee</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-203570</link>
		<dc:creator><![CDATA[Dee]]></dc:creator>
		<pubDate>Thu, 24 Nov 2011 09:44:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-203570</guid>
		<description><![CDATA[how to create a sql server job that runs once in every year on specific date and time????]]></description>
		<content:encoded><![CDATA[<p>how to create a sql server job that runs once in every year on specific date and time????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sheila</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-183719</link>
		<dc:creator><![CDATA[Sheila]]></dc:creator>
		<pubDate>Wed, 26 Oct 2011 13:08:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-183719</guid>
		<description><![CDATA[Hi, I am writing to try and get resolution to a problem I am having.  I have a new install of SQL 2008R2 and I have set up maintenance plans to backup the databases.  I have scheduled the jobs to run at 10 pm.  The first evening the jobs ran fine, then they stopped running.  The new server is on a different domain, so I changed the jobs to use a sql login from my AD login.  I can run the jobs manually at any time.  I can even get the jobs to run if I set the schedule to run at 8 AM, but the jobs will not run on the 10pm schedule.  What am I missing?  Thanks in advance for any advice.]]></description>
		<content:encoded><![CDATA[<p>Hi, I am writing to try and get resolution to a problem I am having.  I have a new install of SQL 2008R2 and I have set up maintenance plans to backup the databases.  I have scheduled the jobs to run at 10 pm.  The first evening the jobs ran fine, then they stopped running.  The new server is on a different domain, so I changed the jobs to use a sql login from my AD login.  I can run the jobs manually at any time.  I can even get the jobs to run if I set the schedule to run at 8 AM, but the jobs will not run on the 10pm schedule.  What am I missing?  Thanks in advance for any advice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-170602</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 22 Sep 2011 08:56:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-170602</guid>
		<description><![CDATA[In the job schedule option goto

Frequency--&gt;The--&gt;Select Last--&gt;select day--&gt;select 3 months]]></description>
		<content:encoded><![CDATA[<p>In the job schedule option goto</p>
<p>Frequency&#8211;&gt;The&#8211;&gt;Select Last&#8211;&gt;select day&#8211;&gt;select 3 months</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-170376</link>
		<dc:creator><![CDATA[Derek]]></dc:creator>
		<pubDate>Wed, 21 Sep 2011 16:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-170376</guid>
		<description><![CDATA[..oh and make sure you set the start date in the future, there&#039;s a bug where if it&#039;s in the past then the nex run date is only 1 month hence.
see https://connect.microsoft.com/SQLServer/feedback/details/620914/sqlagent-scheduling-every-6-months]]></description>
		<content:encoded><![CDATA[<p>..oh and make sure you set the start date in the future, there&#8217;s a bug where if it&#8217;s in the past then the nex run date is only 1 month hence.<br />
see <a href="https://connect.microsoft.com/SQLServer/feedback/details/620914/sqlagent-scheduling-every-6-months" rel="nofollow">https://connect.microsoft.com/SQLServer/feedback/details/620914/sqlagent-scheduling-every-6-months</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-170369</link>
		<dc:creator><![CDATA[Derek]]></dc:creator>
		<pubDate>Wed, 21 Sep 2011 15:51:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-170369</guid>
		<description><![CDATA[Set up 4 schedules for that job, in the first case, on the 31st day recurring every 12 months with a start date of  01/31]]></description>
		<content:encoded><![CDATA[<p>Set up 4 schedules for that job, in the first case, on the 31st day recurring every 12 months with a start date of  01/31</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amar</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-170238</link>
		<dc:creator><![CDATA[Amar]]></dc:creator>
		<pubDate>Wed, 21 Sep 2011 09:20:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-170238</guid>
		<description><![CDATA[Hi Pinal,

This is my first quaery on your blog..
My reuirement is I wanted to shedule my job to run on particular date
of every year and the dates are
01/31
04/30
07/31
10/31 

Please suggest me solution for this.]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>This is my first quaery on your blog..<br />
My reuirement is I wanted to shedule my job to run on particular date<br />
of every year and the dates are<br />
01/31<br />
04/30<br />
07/31<br />
10/31 </p>
<p>Please suggest me solution for this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-157819</link>
		<dc:creator><![CDATA[Derek]]></dc:creator>
		<pubDate>Tue, 16 Aug 2011 13:44:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-157819</guid>
		<description><![CDATA[please change the &#039;alter&#039; to a &#039;create&#039; for me in the above code. Thanks.]]></description>
		<content:encoded><![CDATA[<p>please change the &#8216;alter&#8217; to a &#8216;create&#8217; for me in the above code. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-157817</link>
		<dc:creator><![CDATA[Derek]]></dc:creator>
		<pubDate>Tue, 16 Aug 2011 13:43:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-157817</guid>
		<description><![CDATA[Well, it seems master.dbo.xp_sqlagent_enum_jobs is the answer. 
This undocumented sproc sees the SQL Agent updates immediately.
I&#039;ve written a sproc to return the next run date &amp; time as a datetime given the name of the job. I hope this helps someone out there, I know I could have done with it a few months ago and it&#039;s good to give something back.

Regards

Derek


/****** Object:  UserDefinedFunction [dbo].[udfGetDateTimeFromInteger]    Script Date: 08/16/2011 14:38:17 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/* =============================================
-- Author:		Derek Robinson
-- Create date: 25/05/11
-- Description:	return a datetime based on  2 integers passed
	(used with scheduled jobs)
	
-- Usage:	select dbo.udfGetDateTimeFromInteger(20110601, 0)		  
-- Returns: equivalent datetime

-- =============================================*/
CREATE FUNCTION [dbo].[udfGetDateTimeFromInteger] 
(
	 @intDate int,
	 @intTime int
)
RETURNS datetime
AS
BEGIN
	-- Declare the return variable here
	DECLARE	@DT_datetime datetime = NULL,
				@str_date varchar(11),
				@str_time varchar(8)
	if(@intDate is not null and @intDate &gt; 0)				
	begin
		select @str_date = CONVERT(varchar(11),@intDate)
		select @str_date = SUBSTRING(@str_date,1,4)+&#039;/&#039;+SUBSTRING(@str_date,5,2)+&#039;/&#039;+SUBSTRING(@str_date,7,2)
		if @intTime=0
			select @str_time =&#039;000000&#039;
		else
			select @str_time = right(&#039;0&#039;+CONVERT(varchar(11),@intTime),6)
		select @str_time = SUBSTRING(@str_time,1,2)+&#039;:&#039;+SUBSTRING(@str_time,3,2)+&#039;:&#039;+SUBSTRING(@str_time,5,2)
		
		select @DT_datetime = CAST(@str_date+&#039; &#039;+@str_time as datetime)
	end
	-- Return the result of the function
	RETURN @DT_datetime

END

GO


/* =============================================
-- Author:		Derek Robinson
-- Create date: 16/08/11
-- Description:	return a datetime on the next run date/time of a give @job_name
	uses undocumented proc xp_sqlagent_enum_jobs. Circumvents the 20 min delay in
	refreshing sysjobschedules. For those of us where 20 minutes is a lifetime.
	
-- Example usage: (highlight and run)
	declare @nextRunDateTime datetime 
	exec uspGetNextRunDateTime @job_name=&#039;ValueLink Price File Output&#039;, @nextRunDateTime = @nextRunDateTime output
	select @nextRunDateTime 
		  
-- Returns:	datetime of next run or NULL if not found

-- =============================================*/
alter proc [dbo].[uspGetNextRunDateTime] 
(
	 @job_name varchar(250),
	 @nextRunDateTime datetime output
)
as
BEGIN

create table #xp_results(
	job_id uniqueidentifier not null,
	last_run_date int not null,
	last_run_time int not null,
	next_run_date int not null,
	next_run_time int not null,
	next_run_schedule_id int not null,
	requested_to_run int not null, -- bool
	request_source int not null,
	request_source_id sysname collate database_default null,
	running int not null, -- bool
	current_step int not null,
	current_retry_attempt int not null,
	job_state int not null )

insert #xp_results exec master.dbo.xp_sqlagent_enum_jobs @is_sysadmin = 1, @job_owner = &#039;&#039;

select @nextRunDateTime = dbo.udfGetDateTimeFromInteger(r.next_run_date, r.next_run_time)
from #xp_results r inner join msdb..sysjobs j on
r.job_id = j.job_id 
where j.name = @job_name

drop table #xp_results

RETURN 

END]]></description>
		<content:encoded><![CDATA[<p>Well, it seems master.dbo.xp_sqlagent_enum_jobs is the answer.<br />
This undocumented sproc sees the SQL Agent updates immediately.<br />
I&#8217;ve written a sproc to return the next run date &amp; time as a datetime given the name of the job. I hope this helps someone out there, I know I could have done with it a few months ago and it&#8217;s good to give something back.</p>
<p>Regards</p>
<p>Derek</p>
<p>/****** Object:  UserDefinedFunction [dbo].[udfGetDateTimeFromInteger]    Script Date: 08/16/2011 14:38:17 ******/<br />
SET ANSI_NULLS ON<br />
GO</p>
<p>SET QUOTED_IDENTIFIER ON<br />
GO</p>
<p>/* =============================================<br />
&#8211; Author:		Derek Robinson<br />
&#8211; Create date: 25/05/11<br />
&#8211; Description:	return a datetime based on  2 integers passed<br />
	(used with scheduled jobs)</p>
<p>&#8211; Usage:	select dbo.udfGetDateTimeFromInteger(20110601, 0)<br />
&#8211; Returns: equivalent datetime</p>
<p>&#8211; =============================================*/<br />
CREATE FUNCTION [dbo].[udfGetDateTimeFromInteger]<br />
(<br />
	 @intDate int,<br />
	 @intTime int<br />
)<br />
RETURNS datetime<br />
AS<br />
BEGIN<br />
	&#8211; Declare the return variable here<br />
	DECLARE	@DT_datetime datetime = NULL,<br />
				@str_date varchar(11),<br />
				@str_time varchar(8)<br />
	if(@intDate is not null and @intDate &gt; 0)<br />
	begin<br />
		select @str_date = CONVERT(varchar(11),@intDate)<br />
		select @str_date = SUBSTRING(@str_date,1,4)+&#8217;/'+SUBSTRING(@str_date,5,2)+&#8217;/'+SUBSTRING(@str_date,7,2)<br />
		if @intTime=0<br />
			select @str_time =&#8217;000000&#8242;<br />
		else<br />
			select @str_time = right(&#8217;0&#8242;+CONVERT(varchar(11),@intTime),6)<br />
		select @str_time = SUBSTRING(@str_time,1,2)+&#8217;:'+SUBSTRING(@str_time,3,2)+&#8217;:'+SUBSTRING(@str_time,5,2)</p>
<p>		select @DT_datetime = CAST(@str_date+&#8217; &#8216;+@str_time as datetime)<br />
	end<br />
	&#8211; Return the result of the function<br />
	RETURN @DT_datetime</p>
<p>END</p>
<p>GO</p>
<p>/* =============================================<br />
&#8211; Author:		Derek Robinson<br />
&#8211; Create date: 16/08/11<br />
&#8211; Description:	return a datetime on the next run date/time of a give @job_name<br />
	uses undocumented proc xp_sqlagent_enum_jobs. Circumvents the 20 min delay in<br />
	refreshing sysjobschedules. For those of us where 20 minutes is a lifetime.</p>
<p>&#8211; Example usage: (highlight and run)<br />
	declare @nextRunDateTime datetime<br />
	exec uspGetNextRunDateTime @job_name=&#8217;ValueLink Price File Output&#8217;, @nextRunDateTime = @nextRunDateTime output<br />
	select @nextRunDateTime </p>
<p>&#8211; Returns:	datetime of next run or NULL if not found</p>
<p>&#8211; =============================================*/<br />
alter proc [dbo].[uspGetNextRunDateTime]<br />
(<br />
	 @job_name varchar(250),<br />
	 @nextRunDateTime datetime output<br />
)<br />
as<br />
BEGIN</p>
<p>create table #xp_results(<br />
	job_id uniqueidentifier not null,<br />
	last_run_date int not null,<br />
	last_run_time int not null,<br />
	next_run_date int not null,<br />
	next_run_time int not null,<br />
	next_run_schedule_id int not null,<br />
	requested_to_run int not null, &#8212; bool<br />
	request_source int not null,<br />
	request_source_id sysname collate database_default null,<br />
	running int not null, &#8212; bool<br />
	current_step int not null,<br />
	current_retry_attempt int not null,<br />
	job_state int not null )</p>
<p>insert #xp_results exec master.dbo.xp_sqlagent_enum_jobs @is_sysadmin = 1, @job_owner = &#8221;</p>
<p>select @nextRunDateTime = dbo.udfGetDateTimeFromInteger(r.next_run_date, r.next_run_time)<br />
from #xp_results r inner join msdb..sysjobs j on<br />
r.job_id = j.job_id<br />
where j.name = @job_name</p>
<p>drop table #xp_results</p>
<p>RETURN </p>
<p>END</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-157765</link>
		<dc:creator><![CDATA[Derek]]></dc:creator>
		<pubDate>Tue, 16 Aug 2011 11:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-157765</guid>
		<description><![CDATA[Just remember that sysjobschedules refreshes every 20 minutes (http://msdn.microsoft.com/en-us/library/ms188924.aspx), so may not reflect recent job runs. So what appears as a bug with no refresh of next run datetime is just a SQLAgent thing which magically disappears (probably after you&#039;ve tried a few things so you put it down to your own genius). 
I&#039;ve looked hard but can&#039;t find how to force it to refresh or change the 20 minutes to something more acceptable, even with 2k8R2.]]></description>
		<content:encoded><![CDATA[<p>Just remember that sysjobschedules refreshes every 20 minutes (<a href="http://msdn.microsoft.com/en-us/library/ms188924.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms188924.aspx</a>), so may not reflect recent job runs. So what appears as a bug with no refresh of next run datetime is just a SQLAgent thing which magically disappears (probably after you&#8217;ve tried a few things so you put it down to your own genius).<br />
I&#8217;ve looked hard but can&#8217;t find how to force it to refresh or change the 20 minutes to something more acceptable, even with 2k8R2.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Johnson</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-133983</link>
		<dc:creator><![CDATA[Mark Johnson]]></dc:creator>
		<pubDate>Wed, 11 May 2011 14:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-133983</guid>
		<description><![CDATA[Great script just what i needed thanks.]]></description>
		<content:encoded><![CDATA[<p>Great script just what i needed thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RGP</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-89081</link>
		<dc:creator><![CDATA[RGP]]></dc:creator>
		<pubDate>Thu, 23 Sep 2010 08:51:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-89081</guid>
		<description><![CDATA[thats a bug, the very next day I could see the job history]]></description>
		<content:encoded><![CDATA[<p>thats a bug, the very next day I could see the job history</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RGP</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-88931</link>
		<dc:creator><![CDATA[RGP]]></dc:creator>
		<pubDate>Wed, 22 Sep 2010 09:58:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-88931</guid>
		<description><![CDATA[Hi,

I have scheduled a sql 2005 job to run at 1am in the morning, 
example:

10-09-10 &gt; I created a job

So the job properties show scheduled for the first run on 11-09-10 , 1 am.

Now, when I checked the job history on 11-09-10 I didnt see any job history for it.

Howver I could see that the last executed date was 11-09-10, but no job history.

Please advice.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have scheduled a sql 2005 job to run at 1am in the morning,<br />
example:</p>
<p>10-09-10 &gt; I created a job</p>
<p>So the job properties show scheduled for the first run on 11-09-10 , 1 am.</p>
<p>Now, when I checked the job history on 11-09-10 I didnt see any job history for it.</p>
<p>Howver I could see that the last executed date was 11-09-10, but no job history.</p>
<p>Please advice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jayant dass</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-79899</link>
		<dc:creator><![CDATA[jayant dass]]></dc:creator>
		<pubDate>Mon, 12 Jul 2010 14:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-79899</guid>
		<description><![CDATA[Hi

1. I want a report when job start execute and finish then I Can calculate how much time taken to execute a particular job using TSQL

2.  Retrive all DTS or SSIS package schdule on server 


Thanks in advance

Regards
Jayant Dass]]></description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>1. I want a report when job start execute and finish then I Can calculate how much time taken to execute a particular job using TSQL</p>
<p>2.  Retrive all DTS or SSIS package schdule on server </p>
<p>Thanks in advance</p>
<p>Regards<br />
Jayant Dass</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eRanga</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-61553</link>
		<dc:creator><![CDATA[eRanga]]></dc:creator>
		<pubDate>Sun, 21 Feb 2010 22:27:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-61553</guid>
		<description><![CDATA[Is there any way that I can update the next run time with a script ?

I have applied,

Update sysjobschedules
set next_run_date = CONVERT( VARCHAR(10) , GETDATE()+1,112)
 where job_id=&#039;9F505A75-8A76-48F3-A4E1-12336DA0DF64&#039;

and it says success but doesnt reflect the results on job activity monitor.]]></description>
		<content:encoded><![CDATA[<p>Is there any way that I can update the next run time with a script ?</p>
<p>I have applied,</p>
<p>Update sysjobschedules<br />
set next_run_date = CONVERT( VARCHAR(10) , GETDATE()+1,112)<br />
 where job_id=&#8217;9F505A75-8A76-48F3-A4E1-12336DA0DF64&#8242;</p>
<p>and it says success but doesnt reflect the results on job activity monitor.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brembot</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-57688</link>
		<dc:creator><![CDATA[Brembot]]></dc:creator>
		<pubDate>Wed, 18 Nov 2009 08:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-57688</guid>
		<description><![CDATA[Is there a way to know that the scheduled jobs are NOT running on a specified time schedule? I encounter this one once we restarted the server and the jobs schedule missed.]]></description>
		<content:encoded><![CDATA[<p>Is there a way to know that the scheduled jobs are NOT running on a specified time schedule? I encounter this one once we restarted the server and the jobs schedule missed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: guhPuntee</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-45322</link>
		<dc:creator><![CDATA[guhPuntee]]></dc:creator>
		<pubDate>Sun, 04 Jan 2009 01:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-45322</guid>
		<description><![CDATA[Hi all!

My name is James and I&#039;m new here &lt;a href=&quot;http://www.acairainforest.com&quot; rel=&quot;nofollow&quot;&gt;:)&lt;/a&gt;. So far this is an incredible place for information and I have spent a ton of time reading and browsing around. Look forward to hearing from you!]]></description>
		<content:encoded><![CDATA[<p>Hi all!</p>
<p>My name is James and I&#8217;m new here <a href="http://www.acairainforest.com" rel="nofollow">:)</a>. So far this is an incredible place for information and I have spent a ton of time reading and browsing around. Look forward to hearing from you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerry Hung</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-45017</link>
		<dc:creator><![CDATA[Jerry Hung]]></dc:creator>
		<pubDate>Mon, 22 Dec 2008 20:21:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-45017</guid>
		<description><![CDATA[Cleaned it up a bit, it&#039;s useful to have for knowing what the upcoming jobs are without worrying about all the details (frequency, enabled, etc...) where they are many scripts available as well

--------------
USE msdb

;WITH CTE AS (
SELECT schedule_id, job_id, RIGHT(&#039;0&#039;+CAST(next_run_time AS VARCHAR(6)),6) AS next_run_time, next_run_date
FROM sysjobschedules)
	SELECT A.name Job_Name
	--, next_run_date, next_run_time	
	,&#039;Will be running today at &#039;+
	Stuff(Stuff(right(&#039;000000&#039;+Cast(next_run_time as Varchar),6),3,0,&#039;:&#039;),6,0,&#039;:&#039;) &#039;ScheduledAt&#039;
FROM sysjobs A ,CTE B
WHERE A.job_id = B.job_id
	AND cast(cast(next_run_date as varchar(15)) as datetime) = CONVERT(VARCHAR(10),GETDATE(),101)	-- same date
	AND next_run_time &gt; REPLACE(SUBSTRING(CONVERT( VARCHAR(30) , GETDATE(),120),12,10),&#039;:&#039;,&#039;&#039;)		-- compare time
ORDER BY ScheduledAt ASC]]></description>
		<content:encoded><![CDATA[<p>Cleaned it up a bit, it&#8217;s useful to have for knowing what the upcoming jobs are without worrying about all the details (frequency, enabled, etc&#8230;) where they are many scripts available as well</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8211;<br />
USE msdb</p>
<p>;WITH CTE AS (<br />
SELECT schedule_id, job_id, RIGHT(&#8217;0&#8242;+CAST(next_run_time AS VARCHAR(6)),6) AS next_run_time, next_run_date<br />
FROM sysjobschedules)<br />
	SELECT A.name Job_Name<br />
	&#8211;, next_run_date, next_run_time<br />
	,&#8217;Will be running today at &#8216;+<br />
	Stuff(Stuff(right(&#8217;000000&#8242;+Cast(next_run_time as Varchar),6),3,0,&#8217;:'),6,0,&#8217;:') &#8216;ScheduledAt&#8217;<br />
FROM sysjobs A ,CTE B<br />
WHERE A.job_id = B.job_id<br />
	AND cast(cast(next_run_date as varchar(15)) as datetime) = CONVERT(VARCHAR(10),GETDATE(),101)	&#8211; same date<br />
	AND next_run_time &gt; REPLACE(SUBSTRING(CONVERT( VARCHAR(30) , GETDATE(),120),12,10),&#8217;:',&#8221;)		&#8211; compare time<br />
ORDER BY ScheduledAt ASC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bobby Rentfro</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-45014</link>
		<dc:creator><![CDATA[Bobby Rentfro]]></dc:creator>
		<pubDate>Mon, 22 Dec 2008 18:22:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-45014</guid>
		<description><![CDATA[1. Replace all the single quotes after copying and pasting the code.  Mine always replace the single quotes with another character for some reason.  

2. Replace the CTE in the from clause with an embedded subselect:
FROM sysjobs A ,(SELECT schedule_id, job_id, RIGHT(‘0′+CAST(next_run_time AS VARCHAR(6)),6) AS next_run_time, next_run_date
FROM sysjobschedules) CTE

3. Comment out lines 2 and 3 

4. Run the script.]]></description>
		<content:encoded><![CDATA[<p>1. Replace all the single quotes after copying and pasting the code.  Mine always replace the single quotes with another character for some reason.  </p>
<p>2. Replace the CTE in the from clause with an embedded subselect:<br />
FROM sysjobs A ,(SELECT schedule_id, job_id, RIGHT(‘0′+CAST(next_run_time AS VARCHAR(6)),6) AS next_run_time, next_run_date<br />
FROM sysjobschedules) CTE</p>
<p>3. Comment out lines 2 and 3 </p>
<p>4. Run the script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek W</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-45007</link>
		<dc:creator><![CDATA[Derek W]]></dc:creator>
		<pubDate>Mon, 22 Dec 2008 15:40:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-45007</guid>
		<description><![CDATA[When I ran it, I received this error:

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near &#039;‘&#039;.
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near &#039;‘&#039;.]]></description>
		<content:encoded><![CDATA[<p>When I ran it, I received this error:</p>
<p>Msg 102, Level 15, State 1, Line 2<br />
Incorrect syntax near &#8216;‘&#8217;.<br />
Msg 102, Level 15, State 1, Line 5<br />
Incorrect syntax near &#8216;‘&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/#comment-44990</link>
		<dc:creator><![CDATA[Imran Mohammed]]></dc:creator>
		<pubDate>Mon, 22 Dec 2008 01:39:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1820#comment-44990</guid>
		<description><![CDATA[Hello Pinal,

Thanks for publishing this comment. 

I remember the question was something like this,

I wanted to know the jobs that are scheduled for today and not yet executed. 

So I wrote this script in a way that it will check for todays job and also it will check for time, say its 4 PM now... it will list all the jobs that are scheduled to run after 4 PM... ( today ), it will not list those jobs before 4 PM ( in our example)

I wrote this script in hurry as I was leaving to home from my job... so I did not check it completely... Thanks for fixing it.

Thanks
IM.]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal,</p>
<p>Thanks for publishing this comment. </p>
<p>I remember the question was something like this,</p>
<p>I wanted to know the jobs that are scheduled for today and not yet executed. </p>
<p>So I wrote this script in a way that it will check for todays job and also it will check for time, say its 4 PM now&#8230; it will list all the jobs that are scheduled to run after 4 PM&#8230; ( today ), it will not list those jobs before 4 PM ( in our example)</p>
<p>I wrote this script in hurry as I was leaving to home from my job&#8230; so I did not check it completely&#8230; Thanks for fixing it.</p>
<p>Thanks<br />
IM.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

