--**************************************************************************************************
--*
--*   This script will create the SQL Server tables needed for Microsoft Project Server views.
--*
--*   Privileges needed: member of db_owner or db_ddladmin
--*
--*   Comments
--*   -----------------------------------------------------------------------------------------
--*     1 - In order to specify non-default filegroups, uncomment the "-- ON [PRIMARY]" line 
--*         within each CREATE statement and replace "Primary" with the desired filegroup
--*
--**************************************************************************************************

--**************************************************************************************************
--*      MSP_VIEW_PROJ_ASSN_TP_BY_MINUTE
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MINUTE') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MINUTE
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MINUTE
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   AssignmentUniqueID                        int      NULL,

   AssignmentTimeStart                       datetime       NULL,
   AssignmentTimeFinish                      datetime       NULL,
   AssignmentTimeActualCost                  decimal(25,6)  NULL,
   AssignmentTimeActualOvertimeWork          decimal(25,6)  NULL,
   AssignmentTimeActualWork                  decimal(25,6)  NULL,
   AssignmentTimeACWP                        decimal(25,6)  NULL,
   AssignmentTimeBaselineCost                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Cost              decimal(25,6)  NULL,
   AssignmentTimeBaselineWork                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Work              decimal(25,6)  NULL,
   AssignmentTimeBCWP                        decimal(25,6)  NULL,
   AssignmentTimeBCWS                        decimal(25,6)  NULL,
   AssignmentTimeCost                        decimal(25,6)  NULL,
   AssignmentTimeCumulativeCost              decimal(25,6)  NULL,
   AssignmentTimeCumulativeWork              decimal(25,6)  NULL,
   AssignmentTimeCV                          decimal(25,6)  NULL,
   AssignmentTimeOvertimeWork                decimal(25,6)  NULL,
   AssignmentTimePeakUnits                   decimal(25,6)  NULL,
   AssignmentTimePercentAllocation           decimal(25,6)  NULL,
   AssignmentTimeRegularWork                 decimal(25,6)  NULL,
   AssignmentTimeSV                          decimal(25,6)  NULL,
   AssignmentTimeWork                        decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_TP_BY_MINUTE 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MINUTE(WPROJ_ID, AssignmentUniqueID, AssignmentTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_ASSN_TP_BY_MINUTE_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MINUTE(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_ASSN_TP_BY_HOUR
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_ASSN_TP_BY_HOUR') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_HOUR
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_HOUR
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   AssignmentUniqueID                        int      NULL,

   AssignmentTimeStart                       datetime       NULL,
   AssignmentTimeFinish                      datetime       NULL,
   AssignmentTimeActualCost                  decimal(25,6)  NULL,
   AssignmentTimeActualOvertimeWork          decimal(25,6)  NULL,
   AssignmentTimeActualWork                  decimal(25,6)  NULL,
   AssignmentTimeACWP                        decimal(25,6)  NULL,
   AssignmentTimeBaselineCost                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Cost              decimal(25,6)  NULL,
   AssignmentTimeBaselineWork                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Work              decimal(25,6)  NULL,
   AssignmentTimeBCWP                        decimal(25,6)  NULL,
   AssignmentTimeBCWS                        decimal(25,6)  NULL,
   AssignmentTimeCost                        decimal(25,6)  NULL,
   AssignmentTimeCumulativeCost              decimal(25,6)  NULL,
   AssignmentTimeCumulativeWork              decimal(25,6)  NULL,
   AssignmentTimeCV                          decimal(25,6)  NULL,
   AssignmentTimeOvertimeWork                decimal(25,6)  NULL,
   AssignmentTimePeakUnits                   decimal(25,6)  NULL,
   AssignmentTimePercentAllocation           decimal(25,6)  NULL,
   AssignmentTimeRegularWork                 decimal(25,6)  NULL,
   AssignmentTimeSV                          decimal(25,6)  NULL,
   AssignmentTimeWork                        decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_TP_BY_HOUR 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_HOUR(WPROJ_ID, AssignmentUniqueID, AssignmentTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_ASSN_TP_BY_HOUR_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_HOUR(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_ASSN_TP_BY_WEEK
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_ASSN_TP_BY_WEEK') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_WEEK
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_WEEK
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   AssignmentUniqueID                        int      NULL,

   AssignmentTimeStart                       datetime       NULL,
   AssignmentTimeFinish                      datetime       NULL,
   AssignmentTimeActualCost                  decimal(25,6)  NULL,
   AssignmentTimeActualOvertimeWork          decimal(25,6)  NULL,
   AssignmentTimeActualWork                  decimal(25,6)  NULL,
   AssignmentTimeACWP                        decimal(25,6)  NULL,
   AssignmentTimeBaselineCost                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Cost              decimal(25,6)  NULL,
   AssignmentTimeBaselineWork                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Work              decimal(25,6)  NULL,
   AssignmentTimeBCWP                        decimal(25,6)  NULL,
   AssignmentTimeBCWS                        decimal(25,6)  NULL,
   AssignmentTimeCost                        decimal(25,6)  NULL,
   AssignmentTimeCumulativeCost              decimal(25,6)  NULL,
   AssignmentTimeCumulativeWork              decimal(25,6)  NULL,
   AssignmentTimeCV                          decimal(25,6)  NULL,
   AssignmentTimeOvertimeWork                decimal(25,6)  NULL,
   AssignmentTimePeakUnits                   decimal(25,6)  NULL,
   AssignmentTimePercentAllocation           decimal(25,6)  NULL,
   AssignmentTimeRegularWork                 decimal(25,6)  NULL,
   AssignmentTimeSV                          decimal(25,6)  NULL,
   AssignmentTimeWork                        decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_TP_BY_WEEK 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_WEEK(WPROJ_ID, AssignmentUniqueID, AssignmentTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_ASSN_TP_BY_WEEK_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_WEEK(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_ASSN_TP_BY_MONTH
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MONTH') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MONTH
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MONTH
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   AssignmentUniqueID                        int      NULL,

   AssignmentTimeStart                       datetime       NULL,
   AssignmentTimeFinish                      datetime       NULL,
   AssignmentTimeActualCost                  decimal(25,6)  NULL,
   AssignmentTimeActualOvertimeWork          decimal(25,6)  NULL,
   AssignmentTimeActualWork                  decimal(25,6)  NULL,
   AssignmentTimeACWP                        decimal(25,6)  NULL,
   AssignmentTimeBaselineCost                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Cost              decimal(25,6)  NULL,
   AssignmentTimeBaselineWork                decimal(25,6)  NULL,
   AssignmentTimeBaseline1Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Work              decimal(25,6)  NULL,
   AssignmentTimeBCWP                        decimal(25,6)  NULL,
   AssignmentTimeBCWS                        decimal(25,6)  NULL,
   AssignmentTimeCost                        decimal(25,6)  NULL,
   AssignmentTimeCumulativeCost              decimal(25,6)  NULL,
   AssignmentTimeCumulativeWork              decimal(25,6)  NULL,
   AssignmentTimeCV                          decimal(25,6)  NULL,
   AssignmentTimeOvertimeWork                decimal(25,6)  NULL,
   AssignmentTimePeakUnits                   decimal(25,6)  NULL,
   AssignmentTimePercentAllocation           decimal(25,6)  NULL,
   AssignmentTimeRegularWork                 decimal(25,6)  NULL,
   AssignmentTimeSV                          decimal(25,6)  NULL,
   AssignmentTimeWork                        decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_TP_BY_MONTH 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MONTH(WPROJ_ID, AssignmentUniqueID, AssignmentTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_ASSN_TP_BY_MONTH_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_MONTH(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_BASELINETASKSPLITS
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_BASELINETASKSPLITS') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_BASELINETASKSPLITS
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_BASELINETASKSPLITS
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   TaskUniqueID                              int      NOT NULL,
   BaselineField                             smallint       NULL,
   BaselineSplitStart                        datetime       NULL,
   BaselineSplitFinish                       datetime       NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_BASELINETASKSPLITS 
ON dbo.MSP_VIEW_PROJ_BASELINETASKSPLITS(WPROJ_ID, TaskUniqueID, BaselineSplitStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_BASELINETASKSPLITS_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_BASELINETASKSPLITS(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_TASK_TP_BY_MINUTE
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   TaskUniqueID                              int      NOT NULL,

   TaskTimeStart                             datetime       NULL,
   TaskTimeFinish                            datetime       NULL,
   TaskTimeActualCost                        decimal(25,6)  NULL,
   TaskTimeActualOvertimeWork                decimal(25,6)  NULL,
   TaskTimeActualWork                        decimal(25,6)  NULL,
   TaskTimeACWP                              decimal(25,6)  NULL,
   TaskTimeBaselineCost                      decimal(25,6)  NULL,
   TaskTimeBaseline1Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline2Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline3Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline4Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline5Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline6Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline7Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline8Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline9Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline10Cost                    decimal(25,6)  NULL,
   TaskTimeBaselineWork                      decimal(25,6)  NULL,
   TaskTimeBaseline1Work                     decimal(25,6)  NULL,
   TaskTimeBaseline2Work                     decimal(25,6)  NULL,
   TaskTimeBaseline3Work                     decimal(25,6)  NULL,
   TaskTimeBaseline4Work                     decimal(25,6)  NULL,
   TaskTimeBaseline5Work                     decimal(25,6)  NULL,
   TaskTimeBaseline6Work                     decimal(25,6)  NULL,
   TaskTimeBaseline7Work                     decimal(25,6)  NULL,
   TaskTimeBaseline8Work                     decimal(25,6)  NULL,
   TaskTimeBaseline9Work                     decimal(25,6)  NULL,
   TaskTimeBaseline10Work                    decimal(25,6)  NULL,
   TaskTimeBCWP                              decimal(25,6)  NULL,
   TaskTimeBCWS                              decimal(25,6)  NULL,
   TaskTimeCost                              decimal(25,6)  NULL,
   TaskTimeCumulativeCost                    decimal(25,6)  NULL,
   TaskTimeCumulativeWork                    decimal(25,6)  NULL,
   TaskTimeCV                                decimal(25,6)  NULL,
   TaskTimeFixedCost                         decimal(25,6)  NULL,
   TaskTimeOvertimeWork                      decimal(25,6)  NULL,
   TaskTimeRegularWork                       decimal(25,6)  NULL,
   TaskTimeSV                                decimal(25,6)  NULL,
   TaskTimeWork                              decimal(25,6)  NULL,
   TaskTimeActualFixedCost                   decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_TASK_TP_BY_MINUTE 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE(WPROJ_ID, TaskUniqueID, TaskTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_TASK_TP_BY_MINUTE_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_RES_TP_BY_MINUTE
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_RES_TP_BY_MINUTE') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_MINUTE
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_MINUTE
(
   WPROJ_ID                                  int 		NOT NULL,
   ProjectUniqueID                           int 		NOT NULL,
   ResourceUniqueID                          int 		NOT NULL,
   ResourceEnterpriseUniqueID                int 		NULL,

   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_RES_TP_BY_MINUTE_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_TP_BY_MINUTE(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_RES_TP_BY_HOUR
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_RES_TP_BY_HOUR') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_HOUR
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_HOUR
(
   WPROJ_ID                                  int 		NOT NULL,
   ProjectUniqueID                           int 		NOT NULL,
   ResourceUniqueID                          int 		NOT NULL,
   ResourceEnterpriseUniqueID                int 		NULL,

   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_RES_TP_BY_HOUR_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_TP_BY_HOUR(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_RES_TP_BY_DAY
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_RES_TP_BY_DAY') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_DAY
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_DAY
(
   WPROJ_ID                                  int 		NOT NULL,
   ProjectUniqueID                           int 		NOT NULL,
   ResourceUniqueID                          int 		NOT NULL,
   ResourceEnterpriseUniqueID                int 		NULL,

   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_RES_TP_BY_DAY_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_TP_BY_DAY(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_RES_TP_BY_WEEK
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_RES_TP_BY_WEEK') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_WEEK
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_WEEK
(
   WPROJ_ID                                  int 		NOT NULL,
   ProjectUniqueID                           int 		NOT NULL,
   ResourceUniqueID                          int 		NOT NULL,
   ResourceEnterpriseUniqueID                int 		NULL,

   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_RES_TP_BY_WEEK_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_TP_BY_WEEK(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_RES_TP_BY_MONTH
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_RES_TP_BY_MONTH') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_MONTH
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_RES_TP_BY_MONTH
(
   WPROJ_ID                                  int 		NOT NULL,
   ProjectUniqueID                           int 		NOT NULL,
   ResourceUniqueID                          int 		NOT NULL,
   ResourceEnterpriseUniqueID                int 		NULL,

   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_RES_TP_BY_MONTH_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_TP_BY_MONTH(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_TASK_TP_BY_MINUTE
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   TaskUniqueID                              int      NOT NULL,

   TaskTimeStart                             datetime       NULL,
   TaskTimeFinish                            datetime       NULL,
   TaskTimeActualCost                        decimal(25,6)  NULL,
   TaskTimeActualOvertimeWork                decimal(25,6)  NULL,
   TaskTimeActualWork                        decimal(25,6)  NULL,
   TaskTimeACWP                              decimal(25,6)  NULL,
   TaskTimeBaselineCost                      decimal(25,6)  NULL,
   TaskTimeBaseline1Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline2Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline3Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline4Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline5Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline6Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline7Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline8Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline9Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline10Cost                    decimal(25,6)  NULL,
   TaskTimeBaselineWork                      decimal(25,6)  NULL,
   TaskTimeBaseline1Work                     decimal(25,6)  NULL,
   TaskTimeBaseline2Work                     decimal(25,6)  NULL,
   TaskTimeBaseline3Work                     decimal(25,6)  NULL,
   TaskTimeBaseline4Work                     decimal(25,6)  NULL,
   TaskTimeBaseline5Work                     decimal(25,6)  NULL,
   TaskTimeBaseline6Work                     decimal(25,6)  NULL,
   TaskTimeBaseline7Work                     decimal(25,6)  NULL,
   TaskTimeBaseline8Work                     decimal(25,6)  NULL,
   TaskTimeBaseline9Work                     decimal(25,6)  NULL,
   TaskTimeBaseline10Work                    decimal(25,6)  NULL,
   TaskTimeBCWP                              decimal(25,6)  NULL,
   TaskTimeBCWS                              decimal(25,6)  NULL,
   TaskTimeCost                              decimal(25,6)  NULL,
   TaskTimeCumulativeCost                    decimal(25,6)  NULL,
   TaskTimeCumulativeWork                    decimal(25,6)  NULL,
   TaskTimeCV                                decimal(25,6)  NULL,
   TaskTimeFixedCost                         decimal(25,6)  NULL,
   TaskTimeOvertimeWork                      decimal(25,6)  NULL,
   TaskTimeRegularWork                       decimal(25,6)  NULL,
   TaskTimeSV                                decimal(25,6)  NULL,
   TaskTimeWork                              decimal(25,6)  NULL,
   TaskTimeActualFixedCost                   decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_TASK_TP_BY_MINUTE 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE(WPROJ_ID, TaskUniqueID, TaskTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_TASK_TP_BY_MINUTE_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_MINUTE(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_TASK_TP_BY_HOUR
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_TASK_TP_BY_HOUR') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_HOUR
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_HOUR
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   TaskUniqueID                              int      NOT NULL,

   TaskTimeStart                             datetime       NULL,
   TaskTimeFinish                            datetime       NULL,
   TaskTimeActualCost                        decimal(25,6)  NULL,
   TaskTimeActualOvertimeWork                decimal(25,6)  NULL,
   TaskTimeActualWork                        decimal(25,6)  NULL,
   TaskTimeACWP                              decimal(25,6)  NULL,
   TaskTimeBaselineCost                      decimal(25,6)  NULL,
   TaskTimeBaseline1Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline2Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline3Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline4Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline5Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline6Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline7Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline8Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline9Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline10Cost                    decimal(25,6)  NULL,
   TaskTimeBaselineWork                      decimal(25,6)  NULL,
   TaskTimeBaseline1Work                     decimal(25,6)  NULL,
   TaskTimeBaseline2Work                     decimal(25,6)  NULL,
   TaskTimeBaseline3Work                     decimal(25,6)  NULL,
   TaskTimeBaseline4Work                     decimal(25,6)  NULL,
   TaskTimeBaseline5Work                     decimal(25,6)  NULL,
   TaskTimeBaseline6Work                     decimal(25,6)  NULL,
   TaskTimeBaseline7Work                     decimal(25,6)  NULL,
   TaskTimeBaseline8Work                     decimal(25,6)  NULL,
   TaskTimeBaseline9Work                     decimal(25,6)  NULL,
   TaskTimeBaseline10Work                    decimal(25,6)  NULL,
   TaskTimeBCWP                              decimal(25,6)  NULL,
   TaskTimeBCWS                              decimal(25,6)  NULL,
   TaskTimeCost                              decimal(25,6)  NULL,
   TaskTimeCumulativeCost                    decimal(25,6)  NULL,
   TaskTimeCumulativeWork                    decimal(25,6)  NULL,
   TaskTimeCV                                decimal(25,6)  NULL,
   TaskTimeFixedCost                         decimal(25,6)  NULL,
   TaskTimeOvertimeWork                      decimal(25,6)  NULL,
   TaskTimeRegularWork                       decimal(25,6)  NULL,
   TaskTimeSV                                decimal(25,6)  NULL,
   TaskTimeWork                              decimal(25,6)  NULL,
   TaskTimeActualFixedCost                   decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_TASK_TP_BY_HOUR 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_HOUR(WPROJ_ID, TaskUniqueID, TaskTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_TASK_TP_BY_HOUR_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_HOUR(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_TASK_TP_BY_WEEK
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_TASK_TP_BY_WEEK') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_WEEK
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_WEEK
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   TaskUniqueID                              int      NOT NULL,

   TaskTimeStart                             datetime       NULL,
   TaskTimeFinish                            datetime       NULL,
   TaskTimeActualCost                        decimal(25,6)  NULL,
   TaskTimeActualOvertimeWork                decimal(25,6)  NULL,
   TaskTimeActualWork                        decimal(25,6)  NULL,
   TaskTimeACWP                              decimal(25,6)  NULL,
   TaskTimeBaselineCost                      decimal(25,6)  NULL,
   TaskTimeBaseline1Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline2Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline3Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline4Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline5Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline6Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline7Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline8Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline9Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline10Cost                    decimal(25,6)  NULL,
   TaskTimeBaselineWork                      decimal(25,6)  NULL,
   TaskTimeBaseline1Work                     decimal(25,6)  NULL,
   TaskTimeBaseline2Work                     decimal(25,6)  NULL,
   TaskTimeBaseline3Work                     decimal(25,6)  NULL,
   TaskTimeBaseline4Work                     decimal(25,6)  NULL,
   TaskTimeBaseline5Work                     decimal(25,6)  NULL,
   TaskTimeBaseline6Work                     decimal(25,6)  NULL,
   TaskTimeBaseline7Work                     decimal(25,6)  NULL,
   TaskTimeBaseline8Work                     decimal(25,6)  NULL,
   TaskTimeBaseline9Work                     decimal(25,6)  NULL,
   TaskTimeBaseline10Work                    decimal(25,6)  NULL,
   TaskTimeBCWP                              decimal(25,6)  NULL,
   TaskTimeBCWS                              decimal(25,6)  NULL,
   TaskTimeCost                              decimal(25,6)  NULL,
   TaskTimeCumulativeCost                    decimal(25,6)  NULL,
   TaskTimeCumulativeWork                    decimal(25,6)  NULL,
   TaskTimeCV                                decimal(25,6)  NULL,
   TaskTimeFixedCost                         decimal(25,6)  NULL,
   TaskTimeOvertimeWork                      decimal(25,6)  NULL,
   TaskTimeRegularWork                       decimal(25,6)  NULL,
   TaskTimeSV                                decimal(25,6)  NULL,
   TaskTimeWork                              decimal(25,6)  NULL,
   TaskTimeActualFixedCost                   decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_TASK_TP_BY_WEEK 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_WEEK(WPROJ_ID, TaskUniqueID, TaskTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_TASK_TP_BY_WEEK_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_WEEK(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_PROJ_TASK_TP_BY_MONTH
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_PROJ_TASK_TP_BY_MONTH') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_MONTH
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_MONTH
(
   WPROJ_ID                                  int      NOT NULL,
   ProjectUniqueID                           int      NOT NULL,
   TaskUniqueID                              int      NOT NULL,

   TaskTimeStart                             datetime       NULL,
   TaskTimeFinish                            datetime       NULL,
   TaskTimeActualCost                        decimal(25,6)  NULL,
   TaskTimeActualOvertimeWork                decimal(25,6)  NULL,
   TaskTimeActualWork                        decimal(25,6)  NULL,
   TaskTimeACWP                              decimal(25,6)  NULL,
   TaskTimeBaselineCost                      decimal(25,6)  NULL,
   TaskTimeBaseline1Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline2Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline3Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline4Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline5Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline6Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline7Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline8Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline9Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline10Cost                    decimal(25,6)  NULL,
   TaskTimeBaselineWork                      decimal(25,6)  NULL,
   TaskTimeBaseline1Work                     decimal(25,6)  NULL,
   TaskTimeBaseline2Work                     decimal(25,6)  NULL,
   TaskTimeBaseline3Work                     decimal(25,6)  NULL,
   TaskTimeBaseline4Work                     decimal(25,6)  NULL,
   TaskTimeBaseline5Work                     decimal(25,6)  NULL,
   TaskTimeBaseline6Work                     decimal(25,6)  NULL,
   TaskTimeBaseline7Work                     decimal(25,6)  NULL,
   TaskTimeBaseline8Work                     decimal(25,6)  NULL,
   TaskTimeBaseline9Work                     decimal(25,6)  NULL,
   TaskTimeBaseline10Work                    decimal(25,6)  NULL,
   TaskTimeBCWP                              decimal(25,6)  NULL,
   TaskTimeBCWS                              decimal(25,6)  NULL,
   TaskTimeCost                              decimal(25,6)  NULL,
   TaskTimeCumulativeCost                    decimal(25,6)  NULL,
   TaskTimeCumulativeWork                    decimal(25,6)  NULL,
   TaskTimeCV                                decimal(25,6)  NULL,
   TaskTimeFixedCost                         decimal(25,6)  NULL,
   TaskTimeOvertimeWork                      decimal(25,6)  NULL,
   TaskTimeRegularWork                       decimal(25,6)  NULL,
   TaskTimeSV                                decimal(25,6)  NULL,
   TaskTimeWork                              decimal(25,6)  NULL,
   TaskTimeActualFixedCost                   decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_TASK_TP_BY_MONTH 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_MONTH(WPROJ_ID, TaskUniqueID, TaskTimeStart) 
-- ON [PRIMARY]
GO


CREATE INDEX I_VIEW_TASK_TP_BY_MONTH_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_MONTH(ProjectUniqueID)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_RES_AVAILABILITY
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_RES_AVAILABILITY') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_RES_AVAILABILITY
GO


CREATE TABLE dbo.MSP_VIEW_RES_AVAILABILITY
(
   ResourceUniqueID                          int      NOT NULL,
   AvailabilityAvailableFrom                 datetime       NULL,
   AvailabilityAvailableTo                   datetime       NULL,
   AvailabilityAvailableUnits                decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_RES_AVAILABILITY 
ON dbo.MSP_VIEW_RES_AVAILABILITY(ResourceUniqueID, AvailabilityAvailableFrom)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_RES_COSTRATES
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_RES_COSTRATES') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_RES_COSTRATES
GO


CREATE TABLE dbo.MSP_VIEW_RES_COSTRATES
(
   ResourceUniqueID                          int      NOT NULL,
   CostRateTable                             smallint       NULL,
   CostFromDate                              datetime       NULL,
   CostToDate                                datetime       NULL,
   CostStandardRate                          decimal(25,6)  NULL,
   CostOvertimeRate                          decimal(25,6)  NULL,
   CostPerUseCost                            decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_RES_COSTRATES 
ON dbo.MSP_VIEW_RES_COSTRATES(ResourceUniqueID, CostFromDate)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_RES_TP_BY_MINUTE
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_RES_TP_BY_MINUTE') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_RES_TP_BY_MINUTE
GO


CREATE TABLE dbo.MSP_VIEW_RES_TP_BY_MINUTE
(
   ResourceUniqueID                          int      NOT NULL,
   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_RES_TP_BY_MINUTE 
ON dbo.MSP_VIEW_RES_TP_BY_MINUTE(ResourceUniqueID, ResourceTimeStart)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_RES_TP_BY_HOUR
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_RES_TP_BY_HOUR') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_RES_TP_BY_HOUR
GO


CREATE TABLE dbo.MSP_VIEW_RES_TP_BY_HOUR
(
   ResourceUniqueID                          int      NOT NULL,
   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_RES_TP_BY_HOUR 
ON dbo.MSP_VIEW_RES_TP_BY_HOUR(ResourceUniqueID, ResourceTimeStart)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_RES_TP_BY_WEEK
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_RES_TP_BY_WEEK') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_RES_TP_BY_WEEK
GO


CREATE TABLE dbo.MSP_VIEW_RES_TP_BY_WEEK
(
   ResourceUniqueID                          int      NOT NULL,
   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_RES_TP_BY_WEEK 
ON dbo.MSP_VIEW_RES_TP_BY_WEEK(ResourceUniqueID, ResourceTimeStart)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*      MSP_VIEW_RES_TP_BY_MONTH
--**************************************************************************************************

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.MSP_VIEW_RES_TP_BY_MONTH') 
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE dbo.MSP_VIEW_RES_TP_BY_MONTH
GO


CREATE TABLE dbo.MSP_VIEW_RES_TP_BY_MONTH
(
   ResourceUniqueID                          int      NOT NULL,
   ResourceTimeStart                         datetime       NULL,
   ResourceTimeFinish                        datetime       NULL,
   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWorkAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL,
)
-- ON [PRIMARY]
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_RES_TP_BY_MONTH 
ON dbo.MSP_VIEW_RES_TP_BY_MONTH(ResourceUniqueID, ResourceTimeStart)
-- ON [PRIMARY]
GO


--**************************************************************************************************
--*		ALTER: MSP_VIEW_PROJ_PROJECTS_STD
--**************************************************************************************************


ALTER TABLE dbo.MSP_VIEW_PROJ_PROJECTS_STD ADD

   ProjectAuthor                             nvarchar(255)  NULL,
   ProjectCategory                           nvarchar(255)  NULL,
   ProjectCompany                            nvarchar(255)  NULL,
   ProjectCreationDate                       datetime       NULL,
   ProjectCriticalSlackLimit                 int            NULL,
   ProjectCurrentDate                        datetime       NULL,
   ProjectDaysPerMonth                       smallint       NULL,
   ProjectDefaultFixedCostAccrual            smallint       NULL,
   ProjectDefaultOvertimeRate                decimal(25,6)  NULL,
   ProjectDefaultStandardRate                decimal(25,6)  NULL,
   ProjectDefaultTaskType                    smallint       NULL,
   ProjectDurationFormat                     smallint       NULL,
   ProjectEditableActualCosts                tinyint        NULL,
   ProjectExpandTimephased                   tinyint        NULL,
   ProjectFYStart                            smallint       NULL,
   ProjectHonorConstraints                   tinyint        NULL,
   ProjectInsertedProjectsLikeSummary        tinyint        NULL,
   ProjectIsResourcePool                     tinyint        NULL,
   ProjectKeywords                           ntext          NULL,
   ProjectLastSaved                          datetime       NULL,
   ProjectManager                            nvarchar(255)  NULL,
   ProjectMinsPerDay                         int            NULL,
   ProjectMinsPerWeek                        int            NULL,
   ProjectMultipleCriticalPaths              tinyint        NULL,
   ProjectNewTasksEffortDriven               tinyint        NULL,
   ProjectNewTasksEstimated                  tinyint        NULL,
   ProjectPoolAttachedTo                     ntext          NULL,
   ProjectRevision                           int            NULL,
   ProjectSavePreviewPicture                 tinyint        NULL,
   ProjectScheduledFromStart                 tinyint        NULL,
   ProjectShowEstimatedDurations             tinyint        NULL,
   ProjectSplitInProgressTasks               tinyint        NULL,
   ProjectSpreadActualCost                   tinyint        NULL,
   ProjectSpreadPercentComplete              tinyint        NULL,
   ProjectSubject                            nvarchar(255)  NULL,
   ProjectTaskUpdatesResource                tinyint        NULL,
   ProjectWorkFormat                         smallint       NULL

GO


--**************************************************************************************************
--*		ALTER: MSP_VIEW_PROJ_PROJECTS_ENT
--**************************************************************************************************


ALTER TABLE dbo.MSP_VIEW_PROJ_PROJECTS_ENT ADD

   ProjectEnterpriseOutlineCode1Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode2Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode3Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode4Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode5Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode6Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode7Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode8Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode9Indicator    smallint       NULL,
   ProjectEnterpriseOutlineCode10Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode11Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode12Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode13Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode14Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode15Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode16Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode17Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode18Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode19Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode20Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode21Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode22Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode23Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode24Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode25Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode26Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode27Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode28Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode29Indicator   smallint       NULL,
   ProjectEnterpriseOutlineCode30Indicator   smallint       NULL

GO


--**************************************************************************************************
--*		ALTER: MSP_VIEW_PROJ_ASSN_TP_BY_DAY
--**************************************************************************************************


ALTER TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_DAY ADD

   AssignmentTimeACWP                        decimal(25,6)  NULL,
   AssignmentTimeBaseline1Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Cost               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Cost              decimal(25,6)  NULL,
   AssignmentTimeBaseline1Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline2Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline3Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline4Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline5Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline6Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline7Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline8Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline9Work               decimal(25,6)  NULL,
   AssignmentTimeBaseline10Work              decimal(25,6)  NULL,
   AssignmentTimeBCWP                        decimal(25,6)  NULL,
   AssignmentTimeBCWS                        decimal(25,6)  NULL,
   AssignmentTimeCV                          decimal(25,6)  NULL,
   AssignmentTimePercentAllocation           decimal(25,6)  NULL,
   AssignmentTimeSV                          decimal(25,6)  NULL

GO


--**************************************************************************************************
--*		ALTER: MSP_VIEW_PROJ_TASK_TP_BY_DAY
--**************************************************************************************************


ALTER TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_DAY ADD

   TaskTimeActualCost                        decimal(25,6)  NULL,
   TaskTimeActualOvertimeWork                decimal(25,6)  NULL,
   TaskTimeActualWork                        decimal(25,6)  NULL,
   TaskTimeACWP                              decimal(25,6)  NULL,
   TaskTimeBaseline1Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline2Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline3Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline4Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline5Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline6Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline7Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline8Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline9Cost                     decimal(25,6)  NULL,
   TaskTimeBaseline10Cost                    decimal(25,6)  NULL,
   TaskTimeBaselineWork                      decimal(25,6)  NULL,
   TaskTimeBaseline1Work                     decimal(25,6)  NULL,
   TaskTimeBaseline2Work                     decimal(25,6)  NULL,
   TaskTimeBaseline3Work                     decimal(25,6)  NULL,
   TaskTimeBaseline4Work                     decimal(25,6)  NULL,
   TaskTimeBaseline5Work                     decimal(25,6)  NULL,
   TaskTimeBaseline6Work                     decimal(25,6)  NULL,
   TaskTimeBaseline7Work                     decimal(25,6)  NULL,
   TaskTimeBaseline8Work                     decimal(25,6)  NULL,
   TaskTimeBaseline9Work                     decimal(25,6)  NULL,
   TaskTimeBaseline10Work                    decimal(25,6)  NULL,
   TaskTimeBCWP                              decimal(25,6)  NULL,
   TaskTimeBCWS                              decimal(25,6)  NULL,
   TaskTimeCost                              decimal(25,6)  NULL,
   TaskTimeCumulativeCost                    decimal(25,6)  NULL,
   TaskTimeCumulativeWork                    decimal(25,6)  NULL,
   TaskTimeCV                                decimal(25,6)  NULL,
   TaskTimeOvertimeWork                      decimal(25,6)  NULL,
   TaskTimeRegularWork                       decimal(25,6)  NULL,
   TaskTimeSV                                decimal(25,6)  NULL,
   TaskTimeWork                              decimal(25,6)  NULL

GO


--**************************************************************************************************
--*		ALTER: MSP_VIEW_RES_TP_BY_DAY
--**************************************************************************************************


ALTER TABLE dbo.MSP_VIEW_RES_TP_BY_DAY ADD

   ResourceTimeActualCost                    decimal(25,6)  NULL,
   ResourceTimeActualOvertimeWork            decimal(25,6)  NULL,
   ResourceTimeActualWork                    decimal(25,6)  NULL,
   ResourceTimeACWP                          decimal(25,6)  NULL,
   ResourceTimeBaselineCost                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Cost                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Cost                decimal(25,6)  NULL,
   ResourceTimeBaselineWork                  decimal(25,6)  NULL,
   ResourceTimeBaseline1Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline2Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline3Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline4Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline5Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline6Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline7Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline8Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline9Work                 decimal(25,6)  NULL,
   ResourceTimeBaseline10Work                decimal(25,6)  NULL,
   ResourceTimeBCWP                          decimal(25,6)  NULL,
   ResourceTimeBCWS                          decimal(25,6)  NULL,
   ResourceTimeCost                          decimal(25,6)  NULL,
   ResourceTimeCumulativeCost                decimal(25,6)  NULL,
   ResourceTimeCumulativeWork                decimal(25,6)  NULL,
   ResourceTimeCV                            decimal(25,6)  NULL,
   ResourceTimeOverallocation                decimal(25,6)  NULL,
   ResourceTimeOvertimeWork                  decimal(25,6)  NULL,
   ResourceTimePeakUnits                     decimal(25,6)  NULL,
   ResourceTimePercentAllocation             decimal(25,6)  NULL,
   ResourceTimeRegularWork                   decimal(25,6)  NULL,
   ResourceTimeRemainingAvailability         decimal(25,6)  NULL,
   ResourceTimeSV                            decimal(25,6)  NULL,
   ResourceTimeUnitAvailability              decimal(25,6)  NULL,
   ResourceTimeWork                          decimal(25,6)  NULL

GO


-- End of script