SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 List Scheduled Jobs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nguyen
Starting Member

8 Posts

Posted - 03/30/2004 :  13:14:56  Show Profile  Reply with Quote
/*
DISPLAYS scheduled jobs ordered by date and time.
I couldn't find a SP to do this so I borrowed some code from
msdb.dbo.sp_get_composite_job_info

Louis Nguyen
*/

CREATE PROCEDURE UtilityJobsSchedule
AS
SET ANSI_WARNINGS OFF
set nocount on
set transaction isolation level read uncommitted

create table #T(
job_id uniqueidentifier,
a2 varchar(100),
a3 varchar(100),
nextrundate varchar(100),
nextruntime varchar(100),
a6 varchar(100),
a7 varchar(100),
a8 varchar(100),
a9 varchar(100),
a10 varchar(100),
a11 varchar(100),
a12 varchar(100),
a13 varchar(100)
)

DECLARE @is_sysadmin INT
DECLARE @job_owner sysname
SELECT @is_sysadmin = ISNULL(IS_SRVROLEMEMBER(N'sysadmin'), 0)
SELECT @job_owner = SUSER_SNAME()
INSERT INTO #T
EXECUTE master.dbo.xp_sqlagent_enum_jobs @is_sysadmin, @job_owner

SELECT sjv.name,fj.nextrundate,
nextruntime=case when len(fj.nextruntime) > 3 then substring(fj.nextruntime,1,len(fj.nextruntime)-2) else fj.nextruntime end
FROM #T fj
JOIN msdb.dbo.sysjobs_view sjv ON (fj.job_id = sjv.job_id and sjv.enabled=1)
ORDER BY fj.nextrundate,
cast(case when len(fj.nextruntime) > 3 then substring(fj.nextruntime,1,len(fj.nextruntime)-2) else fj.nextruntime end as int)

GO
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000