Tables [dbo].[History]
Properties
PropertyValue
Row Count0
Created12:33:30 PM Tuesday, March 06, 2007
Last Modified12:33:31 PM Tuesday, March 06, 2007
Columns
NameData TypeMax Length (Bytes)Allow Nulls
Primary Key PK_History: HistoryIDHistoryIDuniqueidentifier16
No
Cluster Key IX_History: ReportID\SnapshotDateReportIDuniqueidentifier16
No
SnapshotDataIDuniqueidentifier16
No
Cluster Key IX_History: ReportID\SnapshotDateSnapshotDatedatetime8
No
Indexes Indexes
NameColumnsUnique
Primary Key PK_History: HistoryIDPK_HistoryHistoryID
Yes
Cluster Key IX_History: ReportID\SnapshotDateIX_HistoryReportID, SnapshotDate
Yes
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
History_Notifications
Yes
Yes
After Insert
HistoryDelete_SnapshotRefcount
Yes
Yes
After Delete
Permissions
TypeActionOwning Principal
GrantDeleteRSExecRole
GrantInsertRSExecRole
GrantReferencesRSExecRole
GrantSelectRSExecRole
GrantUpdateRSExecRole
SQL Script
CREATE TABLE [dbo].[History]
(
[HistoryID] [uniqueidentifier] NOT NULL,
[ReportID] [uniqueidentifier] NOT NULL,
[SnapshotDataID] [uniqueidentifier] NOT NULL,
[SnapshotDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
CREATE TRIGGER [dbo].[History_Notifications] ON [dbo].[History]
AFTER INSERT
AS
insert
into [dbo].[Event]
([EventID], [EventType], [EventData], [TimeEntered])
select NewID(), 'ReportHistorySnapshotCreated', inserted.[HistoryID], GETUTCDATE()
from inserted

GO
CREATE TRIGGER [dbo].[HistoryDelete_SnapshotRefcount] ON [dbo].[History]
AFTER DELETE
AS
UPDATE [dbo].[SnapshotData]
SET [PermanentRefcount] = [PermanentRefcount] - 1
FROM [SnapshotData] SD INNER JOIN deleted D on SD.[SnapshotDataID] = D.[SnapshotDataID]

GO
ALTER TABLE [dbo].[History] ADD CONSTRAINT [PK_History] PRIMARY KEY NONCLUSTERED ([HistoryID]) ON [PRIMARY]
GO
CREATE UNIQUE CLUSTERED INDEX [IX_History] ON [dbo].[History] ([ReportID], [SnapshotDate]) ON [PRIMARY]
GO
GRANT REFERENCES ON  [dbo].[History] TO [RSExecRole]
GRANT SELECT ON  [dbo].[History] TO [RSExecRole]
GRANT INSERT ON  [dbo].[History] TO [RSExecRole]
GRANT DELETE ON  [dbo].[History] TO [RSExecRole]
GRANT UPDATE ON  [dbo].[History] TO [RSExecRole]
GO
Uses
Used By