Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


get schedule description


get schedule description

Author
Message
matt32
matt32
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 172
Comments posted to this topic are about the item get schedule description
YSLGuru
YSLGuru
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1500 Visits: 1665
Thanks for sharing Matthias. Different strokes for different folks so don't take the below as a criticism, just some of us have different coding styles so if you are like me and prefer for nested Conditions (i.e. the Case nesting) to be laid out in visual manner represenatative of thier nesting level and or use of Convert() iunstead of CAST() then the below is the re-formatted version of Mathias's code.

Again this is just a difference in style.


SELECT S.Schedule_ID,
S.Schedule_uID,
S.[name],
S.Enabled,
S.Freq_Type,
S.Freq_Interval,
S.Freq_Subday_Type,
S.Freq_Subday_Interval,
S.Freq_relative_Interval,
S.Freq_recurrence_Factor,
S.Active_Start_Date,
S.Active_End_Date,
S.Active_Start_Time,
S.Active_End_Time,
S.Date_Created,

Case WHEN S.Freq_Type = 0x1
THEN 'Once on ' + Convert( CHAR(10), Convert(DATETIME,Convert(VARCHAR,S.Active_Start_Date), 102) )
WHEN S.Freq_Type = 0x4 AND S.Freq_Interval > 0
THEN Case WHEN S.Freq_Interval > 1
THEN 'Every ' + Convert(VARCHAR,S.Freq_Interval) + ' days'
ELSE 'Every day'
END

WHEN S.Freq_Type = 0x8
THEN Case WHEN S.Freq_Recurrence_Factor = 1
THEN 'Weekly on '
WHEN S.Freq_Recurrence_Factor > 1
THEN 'Every ' + Convert(VARCHAR,S.Freq_Recurrence_Factor) + ' weeks on '
END

+ Left( Case WHEN S.Freq_Interval & 1 = 1
THEN 'Sunday, '
ELSE ''
END

+ Case WHEN S.Freq_Interval & 2 = 2 THEN 'Monday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 4 = 4 THEN 'Tuesday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 8 = 8 THEN 'Wednesday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 16 = 16 THEN 'Thursday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 32 = 32 THEN 'Friday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 64 = 64 THEN 'Saturday, ' ELSE '' END,

LEN ( Case WHEN S.Freq_Interval & 1 = 1 THEN 'Sunday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 2 = 2 THEN 'Monday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 4 = 4 THEN 'Tuesday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 8 = 8 THEN 'Wednesday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 16 = 16 THEN 'Thursday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 32 = 32 THEN 'Friday, ' ELSE '' END
+ Case WHEN S.Freq_Interval & 64 = 64 THEN 'Saturday, ' ELSE '' END
) - 1
)

WHEN S.Freq_Type = 0x10
THEN Case WHEN S.Freq_Recurrence_Factor = 1
THEN 'Monthly on the '
WHEN S.Freq_Recurrence_Factor > 1
THEN 'Every ' + Convert(VARCHAR,S.Freq_Recurrence_Factor) + ' months on the '
END
+ Convert(VARCHAR,S.Freq_Interval)
+ Case WHEN S.Freq_Interval IN(1, 21, 31)
THEN 'st'
WHEN S.Freq_Interval IN(2, 22)
THEN 'nd'
WHEN S.Freq_Interval IN(3, 23)
THEN 'rd'
ELSE 'th'
END

WHEN S.Freq_Type = 0x20
THEN Case WHEN S.Freq_Recurrence_Factor = 1
THEN 'Monthly on the '
WHEN S.Freq_Recurrence_Factor > 1
THEN 'Every ' + Convert(VARCHAR,S.Freq_Recurrence_Factor) + ' months on the '
END
+ Case S.Freq_relative_interval WHEN 0x01 THEN 'first '
WHEN 0x02 THEN 'second '
WHEN 0x04 THEN 'third '
WHEN 0x08 THEN 'fourth '
WHEN 0x10 THEN 'last '
END
+ Case S.Freq_Interval WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednesday'
WHEN 5 THEN 'Thursday'
WHEN 6 THEN 'Friday'
WHEN 7 THEN 'Saturday'
WHEN 8 THEN 'day'
WHEN 9 THEN 'week day'
WHEN 10 THEN 'weekend day'
END
WHEN S.Freq_Type = 0x40
THEN 'Automatically starts When SQLServerAgent starts.'
WHEN S.Freq_Type = 0x80
THEN 'Starts whenever the CPUs become idle'
ELSE ''
END

+ Case WHEN S.Freq_Subday_Type = 0x1 OR S.Freq_Type = 0x1
THEN ' at ' + Left(S.Active_Start_Time, 2) + ':' + Substring(S.Active_Start_Time, 3, 2) + ':' + Right(S.Active_Start_Time, 2)
WHEN S.Freq_Subday_Type IN(0x2, 0x4, 0x8)
THEN ' every '
+ Convert(VARCHAR,S.Freq_Subday_Interval)
+ Case freq_subday_type WHEN 0x2
THEN ' second'
WHEN 0x4
THEN ' minute'
WHEN 0x8
THEN ' hour'
END

+ Case WHEN S.Freq_Subday_Interval > 1
THEN 's'
ELSE ' '
END

ELSE ' '
END

+ Case WHEN S.Freq_Subday_Type IN(0x2, 0x4, 0x8)
THEN ' between ' + Left(S.Active_Start_Time, 2)
+ ':' + Substring(S.Active_Start_Time, 3, 2)
+ ':' + Right(S.Active_Start_Time, 2)
+ ' and ' + Left(S.Active_End_Time, 2)
+ ':' + Substring(S.Active_End_Time, 3, 2)
+ ':' + Right(S.Active_End_Time, 2)
ELSE ''
END
AS 'schedule'

FROM (SELECT SS.Schedule_ID,
SS.Schedule_uID,
SS.Originating_server_ID,
SS.[Name],
SS.Owner_sID,
SS.Enabled,
SS.Freq_Type,
SS.Freq_Interval,
SS.Freq_Subday_Type,
SS.Freq_Subday_Interval,
SS.Freq_relative_Interval,
SS.Freq_recurrence_Factor,
SS.Active_Start_Date,
SS.Active_End_Date,
Replicate('0', 6 - Len( Convert(VARCHAR,SS.Active_Start_Time))) + Convert(VARCHAR,SS.Active_Start_Time) AS 'Active_Start_Time',
Replicate('0', 6 - Len( Convert(VARCHAR,SS.Active_End_Time))) + Convert(VARCHAR,SS.Active_End_Time) AS 'Active_End_Time',
SS.Date_Created,
SS.Date_Modified,
SS.Version_number

FROM MSDB.dbo.SYSSCHEDULES SS ) AS S



Kindest Regards,

Just say No to Facebook!
Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13381 Visits: 14377
Thanks for posting this code Matthias. Very helpful!

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Iwas Bornready
Iwas Bornready
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12094 Visits: 885
Thanks for the script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search