Tables [dbo].[Schedule]
Properties
PropertyValue
CollationLatin1_General_CI_AS_KS_WS
Row Count0
Created12:33:31 PM Tuesday, March 06, 2007
Last Modified5:14:35 PM Tuesday, March 06, 2007
Columns
NameData TypeMax Length (Bytes)Allow Nulls
Cluster Primary Key PK_ScheduleID: ScheduleIDScheduleIDuniqueidentifier16
No
Indexes IX_Schedule: Name\PathNamenvarchar(260)520
No
StartDatedatetime8
No
Flagsint4
No
NextRunTimedatetime8
Yes
LastRunTimedatetime8
Yes
EndDatedatetime8
Yes
RecurrenceTypeint4
Yes
MinutesIntervalint4
Yes
DaysIntervalint4
Yes
WeeksIntervalint4
Yes
DaysOfWeekint4
Yes
DaysOfMonthint4
Yes
Monthint4
Yes
MonthlyWeekint4
Yes
Stateint4
Yes
LastRunStatusnvarchar(260)520
Yes
ScheduledRunTimeoutint4
Yes
Foreign Keys FK_Schedule_Users: [dbo].[Users].CreatedByIdCreatedByIduniqueidentifier16
No
EventTypenvarchar(260)520
No
EventDatanvarchar(260)520
Yes
Typeint4
No
ConsistancyCheckdatetime8
Yes
Indexes IX_Schedule: Name\PathPathnvarchar(260)520
Yes
Indexes Indexes
NameColumnsUnique
Cluster Primary Key PK_ScheduleID: ScheduleIDPK_ScheduleIDScheduleID
Yes
IX_ScheduleName, Path
Yes
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
Schedule_DeleteAgentJob
Yes
Yes
After Delete
Schedule_UpdateExpiration
Yes
Yes
After Update
Foreign Keys Foreign Keys
NameNo CheckColumns
FK_Schedule_Users
Yes
CreatedById->[dbo].[Users].[UserID]
Permissions
TypeActionOwning Principal
GrantDeleteRSExecRole
GrantInsertRSExecRole
GrantReferencesRSExecRole
GrantSelectRSExecRole
GrantUpdateRSExecRole
SQL Script
CREATE TABLE [dbo].[Schedule]
(
[ScheduleID] [uniqueidentifier] NOT NULL,
[Name] [nvarchar] (260) COLLATE Latin1_General_CI_AS_KS_WS NOT NULL,
[StartDate] [datetime] NOT NULL,
[Flags] [int] NOT NULL,
[NextRunTime] [datetime] NULL,
[LastRunTime] [datetime] NULL,
[EndDate] [datetime] NULL,
[RecurrenceType] [int] NULL,
[MinutesInterval] [int] NULL,
[DaysInterval] [int] NULL,
[WeeksInterval] [int] NULL,
[DaysOfWeek] [int] NULL,
[DaysOfMonth] [int] NULL,
[Month] [int] NULL,
[MonthlyWeek] [int] NULL,
[State] [int] NULL,
[LastRunStatus] [nvarchar] (260) COLLATE Latin1_General_CI_AS_KS_WS NULL,
[ScheduledRunTimeout] [int] NULL,
[CreatedById] [uniqueidentifier] NOT NULL,
[EventType] [nvarchar] (260) COLLATE Latin1_General_CI_AS_KS_WS NOT NULL,
[EventData] [nvarchar] (260) COLLATE Latin1_General_CI_AS_KS_WS NULL,
[Type] [int] NOT NULL,
[ConsistancyCheck] [datetime] NULL,
[Path] [nvarchar] (260) COLLATE Latin1_General_CI_AS_KS_WS NULL
) ON [PRIMARY]
GO
CREATE TRIGGER [dbo].[Schedule_DeleteAgentJob] ON [dbo].[Schedule]
AFTER DELETE
AS
DECLARE id_cursor CURSOR
FOR
SELECT ScheduleID from deleted
OPEN id_cursor
DECLARE @next_id uniqueidentifier
FETCH NEXT FROM id_cursor INTO @next_id
WHILE (@@FETCH_STATUS <> -1)
BEGIN
if (@@FETCH_STATUS <> -2)
BEGIN
exec msdb.dbo.sp_delete_job @job_name = @next_id
END
FETCH NEXT FROM id_cursor INTO @next_id
END
CLOSE id_cursor
DEALLOCATE id_cursor

GO
CREATE TRIGGER [dbo].[Schedule_UpdateExpiration] ON [dbo].[Schedule]
AFTER UPDATE
AS
UPDATE
EC
SET
AbsoluteExpiration = I.NextRunTime
FROM
[ReportServerTempDB].dbo.ExecutionCache AS EC
INNER JOIN ReportSchedule AS RS ON EC.ReportID = RS.ReportID
INNER JOIN inserted AS I ON RS.ScheduleID = I.ScheduleID AND RS.ReportAction = 3

GO
ALTER TABLE [dbo].[Schedule] ADD CONSTRAINT [PK_ScheduleID] PRIMARY KEY CLUSTERED ([ScheduleID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Schedule] ADD CONSTRAINT [IX_Schedule] UNIQUE NONCLUSTERED ([Name], [Path]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Schedule] WITH NOCHECK ADD CONSTRAINT [FK_Schedule_Users] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[Users] ([UserID])
GO
GRANT REFERENCES ON  [dbo].[Schedule] TO [RSExecRole]
GRANT SELECT ON  [dbo].[Schedule] TO [RSExecRole]
GRANT INSERT ON  [dbo].[Schedule] TO [RSExecRole]
GRANT DELETE ON  [dbo].[Schedule] TO [RSExecRole]
GRANT UPDATE ON  [dbo].[Schedule] TO [RSExecRole]
GO
Uses
Used By