/****************************************************************************************************
**
** This script will create the SQL Server tables needed for Microsoft Project Server views.
**
** Privileges needed: member of db_owner or db_ddladmin 
**
****************************************************************************************************/

-- Drop existing tables --

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

CREATE TABLE dbo.MSP_VIEW_PROJ_PROJECTS_STD
(
   WPROJ_ID                                  int NOT NULL 
	CONSTRAINT PK_MSP_VIEW_PROJ_PROJECTS_STD_WPROJ_ID PRIMARY KEY CLUSTERED,
   ProjectUniqueID                           int NOT NULL,
   ProjectCurrencyDigits                     smallint NULL,
   ProjectCurrencyPosition                   smallint NULL,
   ProjectCurrencySymbol                     nvarchar (10) NULL,
   ProjectDefaultFinishTime                  smallint NULL,
   ProjectDefaultStartTime                   smallint NULL,
   ProjectTitle                              nvarchar (255) NULL,
   ProjectCalendarName                       nvarchar (255) NULL,
   ProjectFinishDate                         datetime NULL,
   ProjectStartDate                          datetime NULL,
   ProjectStatusDate                         datetime NULL
)
GO


CREATE INDEX I_VIEW_PROJECTS_STD_PROJECTUNIQUEID
ON dbo.MSP_VIEW_PROJ_PROJECTS_STD(ProjectUniqueID)
GO


CREATE TABLE dbo.MSP_VIEW_PROJ_PROJECTS_ENT
(
   WPROJ_ID                                  int NOT NULL
	CONSTRAINT PK_MSP_VIEW_PROJ_PROJECTS_ENT_WPROJ_ID PRIMARY KEY CLUSTERED,
   ENT_ProjectUniqueID                       int NOT NULL,
   ProjectEnterpriseName                     nvarchar (255) NULL,
   ProjectEnterpriseVersion                  nvarchar (255) NULL,
   ProjectEnterpriseCost1                    decimal (25,6) NULL,
   ProjectEnterpriseCost2                    decimal (25,6) NULL,
   ProjectEnterpriseCost3                    decimal (25,6) NULL,
   ProjectEnterpriseCost4                    decimal (25,6) NULL,
   ProjectEnterpriseCost5                    decimal (25,6) NULL,
   ProjectEnterpriseCost6                    decimal (25,6) NULL,
   ProjectEnterpriseCost7                    decimal (25,6) NULL,
   ProjectEnterpriseCost8                    decimal (25,6) NULL,
   ProjectEnterpriseCost9                    decimal (25,6) NULL,
   ProjectEnterpriseCost10                   decimal (25,6) NULL,
   ProjectEnterpriseCost1Indicator           smallint NULL,
   ProjectEnterpriseCost2Indicator           smallint NULL,
   ProjectEnterpriseCost3Indicator           smallint NULL,
   ProjectEnterpriseCost4Indicator           smallint NULL,
   ProjectEnterpriseCost5Indicator           smallint NULL,
   ProjectEnterpriseCost6Indicator           smallint NULL,
   ProjectEnterpriseCost7Indicator           smallint NULL,
   ProjectEnterpriseCost8Indicator           smallint NULL,
   ProjectEnterpriseCost9Indicator           smallint NULL,
   ProjectEnterpriseCost10Indicator          smallint NULL,
   ProjectEnterpriseDate1                    datetime NULL,
   ProjectEnterpriseDate2                    datetime NULL,
   ProjectEnterpriseDate3                    datetime NULL,
   ProjectEnterpriseDate4                    datetime NULL,
   ProjectEnterpriseDate5                    datetime NULL,
   ProjectEnterpriseDate6                    datetime NULL,
   ProjectEnterpriseDate7                    datetime NULL,
   ProjectEnterpriseDate8                    datetime NULL,
   ProjectEnterpriseDate9                    datetime NULL,
   ProjectEnterpriseDate10                   datetime NULL,
   ProjectEnterpriseDate11                   datetime NULL,
   ProjectEnterpriseDate12                   datetime NULL,
   ProjectEnterpriseDate13                   datetime NULL,
   ProjectEnterpriseDate14                   datetime NULL,
   ProjectEnterpriseDate15                   datetime NULL,
   ProjectEnterpriseDate16                   datetime NULL,
   ProjectEnterpriseDate17                   datetime NULL,
   ProjectEnterpriseDate18                   datetime NULL,
   ProjectEnterpriseDate19                   datetime NULL,
   ProjectEnterpriseDate20                   datetime NULL,
   ProjectEnterpriseDate21                   datetime NULL,
   ProjectEnterpriseDate22                   datetime NULL,
   ProjectEnterpriseDate23                   datetime NULL,
   ProjectEnterpriseDate24                   datetime NULL,
   ProjectEnterpriseDate25                   datetime NULL,
   ProjectEnterpriseDate26                   datetime NULL,
   ProjectEnterpriseDate27                   datetime NULL,
   ProjectEnterpriseDate28                   datetime NULL,
   ProjectEnterpriseDate29                   datetime NULL,
   ProjectEnterpriseDate30                   datetime NULL,
   ProjectEnterpriseDate1Indicator           smallint NULL,
   ProjectEnterpriseDate2Indicator           smallint NULL,
   ProjectEnterpriseDate3Indicator           smallint NULL,
   ProjectEnterpriseDate4Indicator           smallint NULL,
   ProjectEnterpriseDate5Indicator           smallint NULL,
   ProjectEnterpriseDate6Indicator           smallint NULL,
   ProjectEnterpriseDate7Indicator           smallint NULL,
   ProjectEnterpriseDate8Indicator           smallint NULL,
   ProjectEnterpriseDate9Indicator           smallint NULL,
   ProjectEnterpriseDate10Indicator          smallint NULL,
   ProjectEnterpriseDate11Indicator          smallint NULL,
   ProjectEnterpriseDate12Indicator          smallint NULL,
   ProjectEnterpriseDate13Indicator          smallint NULL,
   ProjectEnterpriseDate14Indicator          smallint NULL,
   ProjectEnterpriseDate15Indicator          smallint NULL,
   ProjectEnterpriseDate16Indicator          smallint NULL,
   ProjectEnterpriseDate17Indicator          smallint NULL,
   ProjectEnterpriseDate18Indicator          smallint NULL,
   ProjectEnterpriseDate19Indicator          smallint NULL,
   ProjectEnterpriseDate20Indicator          smallint NULL,
   ProjectEnterpriseDate21Indicator          smallint NULL,
   ProjectEnterpriseDate22Indicator          smallint NULL,
   ProjectEnterpriseDate23Indicator          smallint NULL,
   ProjectEnterpriseDate24Indicator          smallint NULL,
   ProjectEnterpriseDate25Indicator          smallint NULL,
   ProjectEnterpriseDate26Indicator          smallint NULL,
   ProjectEnterpriseDate27Indicator          smallint NULL,
   ProjectEnterpriseDate28Indicator          smallint NULL,
   ProjectEnterpriseDate29Indicator          smallint NULL,
   ProjectEnterpriseDate30Indicator          smallint NULL,
   ProjectEnterpriseDuration1                int NULL,
   ProjectEnterpriseDuration2                int NULL,
   ProjectEnterpriseDuration3                int NULL,
   ProjectEnterpriseDuration4                int NULL,
   ProjectEnterpriseDuration5                int NULL,
   ProjectEnterpriseDuration6                int NULL,
   ProjectEnterpriseDuration7                int NULL,
   ProjectEnterpriseDuration8                int NULL,
   ProjectEnterpriseDuration9                int NULL,
   ProjectEnterpriseDuration10               int NULL,
   ProjectEnterpriseDuration1Indicator       smallint NULL,
   ProjectEnterpriseDuration2Indicator       smallint NULL,
   ProjectEnterpriseDuration3Indicator       smallint NULL,
   ProjectEnterpriseDuration4Indicator       smallint NULL,
   ProjectEnterpriseDuration5Indicator       smallint NULL,
   ProjectEnterpriseDuration6Indicator       smallint NULL,
   ProjectEnterpriseDuration7Indicator       smallint NULL,
   ProjectEnterpriseDuration8Indicator       smallint NULL,
   ProjectEnterpriseDuration9Indicator       smallint NULL,
   ProjectEnterpriseDuration10Indicator      smallint NULL,
   ProjectEnterpriseFlag1                    tinyint NULL,
   ProjectEnterpriseFlag2                    tinyint NULL,
   ProjectEnterpriseFlag3                    tinyint NULL,
   ProjectEnterpriseFlag4                    tinyint NULL,
   ProjectEnterpriseFlag5                    tinyint NULL,
   ProjectEnterpriseFlag6                    tinyint NULL,
   ProjectEnterpriseFlag7                    tinyint NULL,
   ProjectEnterpriseFlag8                    tinyint NULL,
   ProjectEnterpriseFlag9                    tinyint NULL,
   ProjectEnterpriseFlag10                   tinyint NULL,
   ProjectEnterpriseFlag11                   tinyint NULL,
   ProjectEnterpriseFlag12                   tinyint NULL,
   ProjectEnterpriseFlag13                   tinyint NULL,
   ProjectEnterpriseFlag14                   tinyint NULL,
   ProjectEnterpriseFlag15                   tinyint NULL,
   ProjectEnterpriseFlag16                   tinyint NULL,
   ProjectEnterpriseFlag17                   tinyint NULL,
   ProjectEnterpriseFlag18                   tinyint NULL,
   ProjectEnterpriseFlag19                   tinyint NULL,
   ProjectEnterpriseFlag20                   tinyint NULL,
   ProjectEnterpriseFlag1Indicator           smallint NULL,
   ProjectEnterpriseFlag2Indicator           smallint NULL,
   ProjectEnterpriseFlag3Indicator           smallint NULL,
   ProjectEnterpriseFlag4Indicator           smallint NULL,
   ProjectEnterpriseFlag5Indicator           smallint NULL,
   ProjectEnterpriseFlag6Indicator           smallint NULL,
   ProjectEnterpriseFlag7Indicator           smallint NULL,
   ProjectEnterpriseFlag8Indicator           smallint NULL,
   ProjectEnterpriseFlag9Indicator           smallint NULL,
   ProjectEnterpriseFlag10Indicator          smallint NULL,
   ProjectEnterpriseFlag11Indicator          smallint NULL,
   ProjectEnterpriseFlag12Indicator          smallint NULL,
   ProjectEnterpriseFlag13Indicator          smallint NULL,
   ProjectEnterpriseFlag14Indicator          smallint NULL,
   ProjectEnterpriseFlag15Indicator          smallint NULL,
   ProjectEnterpriseFlag16Indicator          smallint NULL,
   ProjectEnterpriseFlag17Indicator          smallint NULL,
   ProjectEnterpriseFlag18Indicator          smallint NULL,
   ProjectEnterpriseFlag19Indicator          smallint NULL,
   ProjectEnterpriseFlag20Indicator          smallint NULL,
   ProjectEnterpriseNumber1                  int NULL,
   ProjectEnterpriseNumber2                  int NULL,
   ProjectEnterpriseNumber3                  int NULL,
   ProjectEnterpriseNumber4                  int NULL,
   ProjectEnterpriseNumber5                  int NULL,
   ProjectEnterpriseNumber6                  int NULL,
   ProjectEnterpriseNumber7                  int NULL,
   ProjectEnterpriseNumber8                  int NULL,
   ProjectEnterpriseNumber9                  int NULL,
   ProjectEnterpriseNumber10                 int NULL,
   ProjectEnterpriseNumber11                 int NULL,
   ProjectEnterpriseNumber12                 int NULL,
   ProjectEnterpriseNumber13                 int NULL,
   ProjectEnterpriseNumber14                 int NULL,
   ProjectEnterpriseNumber15                 int NULL,
   ProjectEnterpriseNumber16                 int NULL,
   ProjectEnterpriseNumber17                 int NULL,
   ProjectEnterpriseNumber18                 int NULL,
   ProjectEnterpriseNumber19                 int NULL,
   ProjectEnterpriseNumber20                 int NULL,
   ProjectEnterpriseNumber21                 int NULL,
   ProjectEnterpriseNumber22                 int NULL,
   ProjectEnterpriseNumber23                 int NULL,
   ProjectEnterpriseNumber24                 int NULL,
   ProjectEnterpriseNumber25                 int NULL,
   ProjectEnterpriseNumber26                 int NULL,
   ProjectEnterpriseNumber27                 int NULL,
   ProjectEnterpriseNumber28                 int NULL,
   ProjectEnterpriseNumber29                 int NULL,
   ProjectEnterpriseNumber30                 int NULL,
   ProjectEnterpriseNumber31                 int NULL,
   ProjectEnterpriseNumber32                 int NULL,
   ProjectEnterpriseNumber33                 int NULL,
   ProjectEnterpriseNumber34                 int NULL,
   ProjectEnterpriseNumber35                 int NULL,
   ProjectEnterpriseNumber36                 int NULL,
   ProjectEnterpriseNumber37                 int NULL,
   ProjectEnterpriseNumber38                 int NULL,
   ProjectEnterpriseNumber39                 int NULL,
   ProjectEnterpriseNumber40                 int NULL,
   ProjectEnterpriseNumber1Indicator         smallint NULL,
   ProjectEnterpriseNumber2Indicator         smallint NULL,
   ProjectEnterpriseNumber3Indicator         smallint NULL,
   ProjectEnterpriseNumber4Indicator         smallint NULL,
   ProjectEnterpriseNumber5Indicator         smallint NULL,
   ProjectEnterpriseNumber6Indicator         smallint NULL,
   ProjectEnterpriseNumber7Indicator         smallint NULL,
   ProjectEnterpriseNumber8Indicator         smallint NULL,
   ProjectEnterpriseNumber9Indicator         smallint NULL,
   ProjectEnterpriseNumber10Indicator        smallint NULL,
   ProjectEnterpriseNumber11Indicator        smallint NULL,
   ProjectEnterpriseNumber12Indicator        smallint NULL,
   ProjectEnterpriseNumber13Indicator        smallint NULL,
   ProjectEnterpriseNumber14Indicator        smallint NULL,
   ProjectEnterpriseNumber15Indicator        smallint NULL,
   ProjectEnterpriseNumber16Indicator        smallint NULL,
   ProjectEnterpriseNumber17Indicator        smallint NULL,
   ProjectEnterpriseNumber18Indicator        smallint NULL,
   ProjectEnterpriseNumber19Indicator        smallint NULL,
   ProjectEnterpriseNumber20Indicator        smallint NULL,
   ProjectEnterpriseNumber21Indicator        smallint NULL,
   ProjectEnterpriseNumber22Indicator        smallint NULL,
   ProjectEnterpriseNumber23Indicator        smallint NULL,
   ProjectEnterpriseNumber24Indicator        smallint NULL,
   ProjectEnterpriseNumber25Indicator        smallint NULL,
   ProjectEnterpriseNumber26Indicator        smallint NULL,
   ProjectEnterpriseNumber27Indicator        smallint NULL,
   ProjectEnterpriseNumber28Indicator        smallint NULL,
   ProjectEnterpriseNumber29Indicator        smallint NULL,
   ProjectEnterpriseNumber30Indicator        smallint NULL,
   ProjectEnterpriseNumber31Indicator        smallint NULL,
   ProjectEnterpriseNumber32Indicator        smallint NULL,
   ProjectEnterpriseNumber33Indicator        smallint NULL,
   ProjectEnterpriseNumber34Indicator        smallint NULL,
   ProjectEnterpriseNumber35Indicator        smallint NULL,
   ProjectEnterpriseNumber36Indicator        smallint NULL,
   ProjectEnterpriseNumber37Indicator        smallint NULL,
   ProjectEnterpriseNumber38Indicator        smallint NULL,
   ProjectEnterpriseNumber39Indicator        smallint NULL,
   ProjectEnterpriseNumber40Indicator        smallint NULL,
   ProjectEnterpriseOutlineCode1ID           integer NULL,
   ProjectEnterpriseOutlineCode2ID           integer NULL,
   ProjectEnterpriseOutlineCode3ID           integer NULL,
   ProjectEnterpriseOutlineCode4ID           integer NULL,
   ProjectEnterpriseOutlineCode5ID           integer NULL,
   ProjectEnterpriseOutlineCode6ID           integer NULL,
   ProjectEnterpriseOutlineCode7ID           integer NULL,
   ProjectEnterpriseOutlineCode8ID           integer NULL,
   ProjectEnterpriseOutlineCode9ID           integer NULL,
   ProjectEnterpriseOutlineCode10ID          integer NULL,
   ProjectEnterpriseOutlineCode11ID          integer NULL,
   ProjectEnterpriseOutlineCode12ID          integer NULL,
   ProjectEnterpriseOutlineCode13ID          integer NULL,
   ProjectEnterpriseOutlineCode14ID          integer NULL,
   ProjectEnterpriseOutlineCode15ID          integer NULL,
   ProjectEnterpriseOutlineCode16ID          integer NULL,
   ProjectEnterpriseOutlineCode17ID          integer NULL,
   ProjectEnterpriseOutlineCode18ID          integer NULL,
   ProjectEnterpriseOutlineCode19ID          integer NULL,
   ProjectEnterpriseOutlineCode20ID          integer NULL,
   ProjectEnterpriseOutlineCode21ID          integer NULL,
   ProjectEnterpriseOutlineCode22ID          integer NULL,
   ProjectEnterpriseOutlineCode23ID          integer NULL,
   ProjectEnterpriseOutlineCode24ID          integer NULL,
   ProjectEnterpriseOutlineCode25ID          integer NULL,
   ProjectEnterpriseOutlineCode26ID          integer NULL,
   ProjectEnterpriseOutlineCode27ID          integer NULL,
   ProjectEnterpriseOutlineCode28ID          integer NULL,
   ProjectEnterpriseOutlineCode29ID          integer NULL,
   ProjectEnterpriseOutlineCode30ID          integer NULL,
   ProjectEnterpriseText1                    ntext NULL,
   ProjectEnterpriseText2                    ntext NULL,
   ProjectEnterpriseText3                    ntext NULL,
   ProjectEnterpriseText4                    ntext NULL,
   ProjectEnterpriseText5                    ntext NULL,
   ProjectEnterpriseText6                    ntext NULL,
   ProjectEnterpriseText7                    ntext NULL,
   ProjectEnterpriseText8                    ntext NULL,
   ProjectEnterpriseText9                    ntext NULL,
   ProjectEnterpriseText10                   ntext NULL,
   ProjectEnterpriseText11                   ntext NULL,
   ProjectEnterpriseText12                   ntext NULL,
   ProjectEnterpriseText13                   ntext NULL,
   ProjectEnterpriseText14                   ntext NULL,
   ProjectEnterpriseText15                   ntext NULL,
   ProjectEnterpriseText16                   ntext NULL,
   ProjectEnterpriseText17                   ntext NULL,
   ProjectEnterpriseText18                   ntext NULL,
   ProjectEnterpriseText19                   ntext NULL,
   ProjectEnterpriseText20                   ntext NULL,
   ProjectEnterpriseText21                   ntext NULL,
   ProjectEnterpriseText22                   ntext NULL,
   ProjectEnterpriseText23                   ntext NULL,
   ProjectEnterpriseText24                   ntext NULL,
   ProjectEnterpriseText25                   ntext NULL,
   ProjectEnterpriseText26                   ntext NULL,
   ProjectEnterpriseText27                   ntext NULL,
   ProjectEnterpriseText28                   ntext NULL,
   ProjectEnterpriseText29                   ntext NULL,
   ProjectEnterpriseText30                   ntext NULL,
   ProjectEnterpriseText31                   ntext NULL,
   ProjectEnterpriseText32                   ntext NULL,
   ProjectEnterpriseText33                   ntext NULL,
   ProjectEnterpriseText34                   ntext NULL,
   ProjectEnterpriseText35                   ntext NULL,
   ProjectEnterpriseText36                   ntext NULL,
   ProjectEnterpriseText37                   ntext NULL,
   ProjectEnterpriseText38                   ntext NULL,
   ProjectEnterpriseText39                   ntext NULL,
   ProjectEnterpriseText40                   ntext NULL,
   ProjectEnterpriseText1Indicator           smallint NULL,
   ProjectEnterpriseText2Indicator           smallint NULL,
   ProjectEnterpriseText3Indicator           smallint NULL,
   ProjectEnterpriseText4Indicator           smallint NULL,
   ProjectEnterpriseText5Indicator           smallint NULL,
   ProjectEnterpriseText6Indicator           smallint NULL,
   ProjectEnterpriseText7Indicator           smallint NULL,
   ProjectEnterpriseText8Indicator           smallint NULL,
   ProjectEnterpriseText9Indicator           smallint NULL,
   ProjectEnterpriseText10Indicator          smallint NULL,
   ProjectEnterpriseText11Indicator          smallint NULL,
   ProjectEnterpriseText12Indicator          smallint NULL,
   ProjectEnterpriseText13Indicator          smallint NULL,
   ProjectEnterpriseText14Indicator          smallint NULL,
   ProjectEnterpriseText15Indicator          smallint NULL,
   ProjectEnterpriseText16Indicator          smallint NULL,
   ProjectEnterpriseText17Indicator          smallint NULL,
   ProjectEnterpriseText18Indicator          smallint NULL,
   ProjectEnterpriseText19Indicator          smallint NULL,
   ProjectEnterpriseText20Indicator          smallint NULL,
   ProjectEnterpriseText21Indicator          smallint NULL,
   ProjectEnterpriseText22Indicator          smallint NULL,
   ProjectEnterpriseText23Indicator          smallint NULL,
   ProjectEnterpriseText24Indicator          smallint NULL,
   ProjectEnterpriseText25Indicator          smallint NULL,
   ProjectEnterpriseText26Indicator          smallint NULL,
   ProjectEnterpriseText27Indicator          smallint NULL,
   ProjectEnterpriseText28Indicator          smallint NULL,
   ProjectEnterpriseText29Indicator          smallint NULL,
   ProjectEnterpriseText30Indicator          smallint NULL,
   ProjectEnterpriseText31Indicator          smallint NULL,
   ProjectEnterpriseText32Indicator          smallint NULL,
   ProjectEnterpriseText33Indicator          smallint NULL,
   ProjectEnterpriseText34Indicator          smallint NULL,
   ProjectEnterpriseText35Indicator          smallint NULL,
   ProjectEnterpriseText36Indicator          smallint NULL,
   ProjectEnterpriseText37Indicator          smallint NULL,
   ProjectEnterpriseText38Indicator          smallint NULL,
   ProjectEnterpriseText39Indicator          smallint NULL,
   ProjectEnterpriseText40Indicator          smallint NULL
)
GO

CREATE INDEX I_VIEW_PROJECTS_ENT_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_PROJECTS_ENT(ENT_ProjectUniqueID) 
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_TASKS_STD
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   TaskUniqueID                              int NOT NULL,
   TaskPercentComplete                       smallint NULL,
   TaskPercentWorkComplete                   smallint NULL,
   TaskActualCost                            decimal (25,6) NULL,
   TaskActualDuration                        int NULL,
   TaskActualFinish                          datetime NULL,
   TaskActualOvertimeCost                    decimal (25,6) NULL,
   TaskActualOvertimeWork                    decimal (25,6) NULL,
   TaskActualStart                           datetime NULL,
   TaskActualWork                            decimal (25,6) NULL,
   TaskACWP                                  decimal (25,6) NULL,
   TaskBaseline1Cost                         decimal (25,6) NULL,
   TaskBaseline2Cost                         decimal (25,6) NULL,
   TaskBaseline3Cost                         decimal (25,6) NULL,
   TaskBaseline4Cost                         decimal (25,6) NULL,
   TaskBaseline5Cost                         decimal (25,6) NULL,
   TaskBaseline6Cost                         decimal (25,6) NULL,
   TaskBaseline7Cost                         decimal (25,6) NULL,
   TaskBaseline8Cost                         decimal (25,6) NULL,
   TaskBaseline9Cost                         decimal (25,6) NULL,
   TaskBaseline10Cost                        decimal (25,6) NULL,
   TaskBaseline1Duration                     int NULL,
   TaskBaseline2Duration                     int NULL,
   TaskBaseline3Duration                     int NULL,
   TaskBaseline4Duration                     int NULL,
   TaskBaseline5Duration                     int NULL,
   TaskBaseline6Duration                     int NULL,
   TaskBaseline7Duration                     int NULL,
   TaskBaseline8Duration                     int NULL,
   TaskBaseline9Duration                     int NULL,
   TaskBaseline10Duration                    int NULL,
   TaskBaseline1DurationEstimated            tinyint NULL,
   TaskBaseline2DurationEstimated            tinyint NULL,
   TaskBaseline3DurationEstimated            tinyint NULL,
   TaskBaseline4DurationEstimated            tinyint NULL,
   TaskBaseline5DurationEstimated            tinyint NULL,
   TaskBaseline6DurationEstimated            tinyint NULL,
   TaskBaseline7DurationEstimated            tinyint NULL,
   TaskBaseline8DurationEstimated            tinyint NULL,
   TaskBaseline9DurationEstimated            tinyint NULL,
   TaskBaseline10DurationEstimated           tinyint NULL,
   TaskBaseline1Finish                       datetime NULL,
   TaskBaseline2Finish                       datetime NULL,
   TaskBaseline3Finish                       datetime NULL,
   TaskBaseline4Finish                       datetime NULL,
   TaskBaseline5Finish                       datetime NULL,
   TaskBaseline6Finish                       datetime NULL,
   TaskBaseline7Finish                       datetime NULL,
   TaskBaseline8Finish                       datetime NULL,
   TaskBaseline9Finish                       datetime NULL,
   TaskBaseline10Finish                      datetime NULL,
   TaskBaseline1Start                        datetime NULL,
   TaskBaseline2Start                        datetime NULL,
   TaskBaseline3Start                        datetime NULL,
   TaskBaseline4Start                        datetime NULL,
   TaskBaseline5Start                        datetime NULL,
   TaskBaseline6Start                        datetime NULL,
   TaskBaseline7Start                        datetime NULL,
   TaskBaseline8Start                        datetime NULL,
   TaskBaseline9Start                        datetime NULL,
   TaskBaseline10Start                       datetime NULL,
   TaskBaseline1Work                         decimal (25,6) NULL,
   TaskBaseline2Work                         decimal (25,6) NULL,
   TaskBaseline3Work                         decimal (25,6) NULL,
   TaskBaseline4Work                         decimal (25,6) NULL,
   TaskBaseline5Work                         decimal (25,6) NULL,
   TaskBaseline6Work                         decimal (25,6) NULL,
   TaskBaseline7Work                         decimal (25,6) NULL,
   TaskBaseline8Work                         decimal (25,6) NULL,
   TaskBaseline9Work                         decimal (25,6) NULL,
   TaskBaseline10Work                        decimal (25,6) NULL,
   TaskBaselineCost                          decimal (25,6) NULL,
   TaskBaselineDuration                      int NULL,
   TaskBaselineDurationEstimated             tinyint NULL,
   TaskBaselineFinish                        datetime NULL,
   TaskBaselineStart                         datetime NULL,
   TaskBaselineWork                          decimal (25,6) NULL,
   TaskBCWP                                  decimal (25,6) NULL,
   TaskBCWS                                  decimal (25,6) NULL,
   TaskCalendar                              ntext NULL,
   TaskCompleteThrough                       datetime NULL,
   TaskConfirmed                             tinyint NULL,
   TaskConstraintDate                        datetime NULL,
   TaskConstraintType                        smallint NULL,
   TaskContact                               ntext NULL,
   TaskCost                                  decimal (25,6) NULL,
   TaskCostVariance                          decimal (25,6) NULL,
   TaskCPI                                   decimal (25,6) NULL,
   TaskCVP                                   smallint NULL,
   TaskCreated                               datetime NULL,
   TaskCritical                              tinyint NULL,
   TaskCV                                    decimal (25,6) NULL,
   TaskDeadline                              datetime NULL,
   TaskDuration                              int NULL,
   TaskDurationElapsed                       int NULL,
   TaskDurationVariance                      int NULL,
   TaskEarlyFinish                           datetime NULL,
   TaskEarlyStart                            datetime NULL,
   TaskEffortDriven                          tinyint NULL,
   TaskEstimated                             tinyint NULL,
   TaskExternalTask                          tinyint NULL,
   TaskEAC                                   decimal (25,6) NULL,
   TaskFinish                                datetime NULL,
   TaskFinishSlack                           int NULL,
   TaskFinishVariance                        int NULL,
   TaskFixedCost                             decimal (25,6) NULL,
   TaskFixedCostAccrual                      smallint NULL,
   TaskFreeSlack                             int NULL,
   TaskHideBar                               tinyint NULL,
   TaskHyperlink                             ntext NULL,
   TaskHyperlinkAddress                      ntext NULL,
   TaskHyperlinkHref                         ntext NULL,
   TaskHyperlinkScreenTip                    ntext NULL,
   TaskHyperlinkSubAddress                   ntext NULL,
   TaskID                                    int NULL,
   TaskIgnoreResourceCalendar                tinyint NULL,
   TaskIsNull                                tinyint NULL,
   TaskLateFinish                            datetime NULL,
   TaskLateStart                             datetime NULL,
   TaskLevelAssignments                      tinyint NULL,
   TaskLevelingCanSplit                      tinyint NULL,
   TaskLevelingDelay                         int NULL,
   TaskLinkedFields                          tinyint NULL,
   TaskMarked                                tinyint NULL,
   TaskMilestone                             tinyint NULL,
   TaskName                                  nvarchar (255) NULL,
   TaskNotes                                 ntext NULL,
   TaskObjects                               int NULL,
   TaskOutlineLevel                          smallint NULL,
   TaskOutlineNumber                         ntext NULL,
   TaskOverallocated                         tinyint NULL,
   TaskOvertimeCost                          decimal (25,6) NULL,
   TaskOvertimeWork                          decimal (25,6) NULL,
   TaskPredecessors                          ntext NULL,
   TaskPreleveledFinish                      datetime NULL,
   TaskPreleveledStart                       datetime NULL,
   TaskPriority                              smallint NULL,
   TaskRecurring                             tinyint NULL,
   TaskRegularWork                           decimal (25,6) NULL,
   TaskRemainingCost                         decimal (25,6) NULL,
   TaskRemainingDuration                     int NULL,
   TaskRemainingOvertimeCost                 decimal (25,6) NULL,
   TaskRemainingOvertimeWork                 decimal (25,6) NULL,
   TaskRemainingWork                         decimal (25,6) NULL,
   TaskResourceGroup                         ntext NULL,
   TaskResourceInitials                      ntext NULL,
   TaskResourceNames                         ntext NULL,
   TaskResourcePhonetics                     ntext NULL,
   TaskResponsePending                       tinyint NULL,
   TaskResume                                datetime NULL,
   TaskRollup                                tinyint NULL,
   TaskSPI                                   decimal (25,6) NULL,
   TaskStart                                 datetime NULL,
   TaskStartVariance                         int NULL,
   TaskStatus                                smallint NULL,
   TaskSVP                                   smallint NULL,
   TaskStartSlack                            int NULL,
   TaskStop                                  datetime NULL,
   TaskSubprojectFile                        ntext NULL,
   TaskSubprojectReadOnly                    tinyint NULL,
   TaskSuccessors                            ntext NULL,
   TaskSummary                               tinyint NULL,
   TaskSummaryProgress                       datetime NULL,
   TaskSV                                    decimal (25,6) NULL,
   TaskTCPI                                  decimal (25,6) NULL,
   TaskTeamStatusPending                     tinyint NULL,
   TaskTotalSlack                            int NULL,
   TaskType                                  smallint NULL,
   TaskUniqueIDPredecessors                  ntext NULL,
   TaskUniqueIDSuccessors                    ntext NULL,
   TaskUpdateNeeded                          tinyint NULL,
   TaskVAC                                   decimal (25,6) NULL,
   TaskWBS                                   ntext NULL,
   TaskWBSPredecessors                       ntext NULL,
   TaskWBSSuccessors                         ntext NULL,
   TaskWork                                  decimal (25,6) NULL,
   TaskWorkVariance                          decimal (25,6) NULL,
   CONSTRAINT PK_MSP_VIEW_PROJ_TASKS_STD_WPROJ_ID_TaskUniqueID PRIMARY KEY CLUSTERED(WPROJ_ID, TaskUniqueID)
)
GO

CREATE INDEX I_VIEW_TASKS_STD_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASKS_STD(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_TASKS_CF
(
   WPROJ_ID                                  int NOT NULL,
   CF_ProjectUniqueID                        int NOT NULL,
   CF_TaskUniqueID                           int NOT NULL,
   TaskCost1                                 decimal (25,6) NULL,
   TaskCost2                                 decimal (25,6) NULL,
   TaskCost3                                 decimal (25,6) NULL,
   TaskCost4                                 decimal (25,6) NULL,
   TaskCost5                                 decimal (25,6) NULL,
   TaskCost6                                 decimal (25,6) NULL,
   TaskCost7                                 decimal (25,6) NULL,
   TaskCost8                                 decimal (25,6) NULL,
   TaskCost9                                 decimal (25,6) NULL,
   TaskCost10                                decimal (25,6) NULL,
   TaskCost1Indicator                        smallint NULL,
   TaskCost2Indicator                        smallint NULL,
   TaskCost3Indicator                        smallint NULL,
   TaskCost4Indicator                        smallint NULL,
   TaskCost5Indicator                        smallint NULL,
   TaskCost6Indicator                        smallint NULL,
   TaskCost7Indicator                        smallint NULL,
   TaskCost8Indicator                        smallint NULL,
   TaskCost9Indicator                        smallint NULL,
   TaskCost10Indicator                       smallint NULL,
   TaskDate1                                 datetime NULL,
   TaskDate2                                 datetime NULL,
   TaskDate3                                 datetime NULL,
   TaskDate4                                 datetime NULL,
   TaskDate5                                 datetime NULL,
   TaskDate6                                 datetime NULL,
   TaskDate7                                 datetime NULL,
   TaskDate8                                 datetime NULL,
   TaskDate9                                 datetime NULL,
   TaskDate10                                datetime NULL,
   TaskDate1Indicator                        smallint NULL,
   TaskDate2Indicator                        smallint NULL,
   TaskDate3Indicator                        smallint NULL,
   TaskDate4Indicator                        smallint NULL,
   TaskDate5Indicator                        smallint NULL,
   TaskDate6Indicator                        smallint NULL,
   TaskDate7Indicator                        smallint NULL,
   TaskDate8Indicator                        smallint NULL,
   TaskDate9Indicator                        smallint NULL,
   TaskDate10Indicator                       smallint NULL,
   TaskDuration1Estimated                    tinyint NULL,
   TaskDuration2Estimated                    tinyint NULL,
   TaskDuration3Estimated                    tinyint NULL,
   TaskDuration4Estimated                    tinyint NULL,
   TaskDuration5Estimated                    tinyint NULL,
   TaskDuration6Estimated                    tinyint NULL,
   TaskDuration7Estimated                    tinyint NULL,
   TaskDuration8Estimated                    tinyint NULL,
   TaskDuration9Estimated                    tinyint NULL,
   TaskDuration10Estimated                   tinyint NULL,
   TaskDuration1                             int NULL,
   TaskDuration2                             int NULL,
   TaskDuration3                             int NULL,
   TaskDuration4                             int NULL,
   TaskDuration5                             int NULL,
   TaskDuration6                             int NULL,
   TaskDuration7                             int NULL,
   TaskDuration8                             int NULL,
   TaskDuration9                             int NULL,
   TaskDuration10                            int NULL,
   TaskDuration1Indicator                    smallint NULL,
   TaskDuration2Indicator                    smallint NULL,
   TaskDuration3Indicator                    smallint NULL,
   TaskDuration4Indicator                    smallint NULL,
   TaskDuration5Indicator                    smallint NULL,
   TaskDuration6Indicator                    smallint NULL,
   TaskDuration7Indicator                    smallint NULL,
   TaskDuration8Indicator                    smallint NULL,
   TaskDuration9Indicator                    smallint NULL,
   TaskDuration10Indicator                   smallint NULL,
   TaskFinish1                               datetime NULL,
   TaskFinish2                               datetime NULL,
   TaskFinish3                               datetime NULL,
   TaskFinish4                               datetime NULL,
   TaskFinish5                               datetime NULL,
   TaskFinish6                               datetime NULL,
   TaskFinish7                               datetime NULL,
   TaskFinish8                               datetime NULL,
   TaskFinish9                               datetime NULL,
   TaskFinish10                              datetime NULL,
   TaskFinish1Indicator                      smallint NULL,
   TaskFinish2Indicator                      smallint NULL,
   TaskFinish3Indicator                      smallint NULL,
   TaskFinish4Indicator                      smallint NULL,
   TaskFinish5Indicator                      smallint NULL,
   TaskFinish6Indicator                      smallint NULL,
   TaskFinish7Indicator                      smallint NULL,
   TaskFinish8Indicator                      smallint NULL,
   TaskFinish9Indicator                      smallint NULL,
   TaskFinish10Indicator                     smallint NULL,
   TaskFlag1                                 tinyint NULL,
   TaskFlag2                                 tinyint NULL,
   TaskFlag3                                 tinyint NULL,
   TaskFlag4                                 tinyint NULL,
   TaskFlag5                                 tinyint NULL,
   TaskFlag6                                 tinyint NULL,
   TaskFlag7                                 tinyint NULL,
   TaskFlag8                                 tinyint NULL,
   TaskFlag9                                 tinyint NULL,
   TaskFlag10                                tinyint NULL,
   TaskFlag11                                tinyint NULL,
   TaskFlag12                                tinyint NULL,
   TaskFlag13                                tinyint NULL,
   TaskFlag14                                tinyint NULL,
   TaskFlag15                                tinyint NULL,
   TaskFlag16                                tinyint NULL,
   TaskFlag17                                tinyint NULL,
   TaskFlag18                                tinyint NULL,
   TaskFlag19                                tinyint NULL,
   TaskFlag20                                tinyint NULL,
   TaskFlag1Indicator                        smallint NULL,
   TaskFlag2Indicator                        smallint NULL,
   TaskFlag3Indicator                        smallint NULL,
   TaskFlag4Indicator                        smallint NULL,
   TaskFlag5Indicator                        smallint NULL,
   TaskFlag6Indicator                        smallint NULL,
   TaskFlag7Indicator                        smallint NULL,
   TaskFlag8Indicator                        smallint NULL,
   TaskFlag9Indicator                        smallint NULL,
   TaskFlag10Indicator                       smallint NULL,
   TaskFlag11Indicator                       smallint NULL,
   TaskFlag12Indicator                       smallint NULL,
   TaskFlag13Indicator                       smallint NULL,
   TaskFlag14Indicator                       smallint NULL,
   TaskFlag15Indicator                       smallint NULL,
   TaskFlag16Indicator                       smallint NULL,
   TaskFlag17Indicator                       smallint NULL,
   TaskFlag18Indicator                       smallint NULL,
   TaskFlag19Indicator                       smallint NULL,
   TaskFlag20Indicator                       smallint NULL,
   TaskNumber1                               decimal (25,6) NULL,
   TaskNumber2                               decimal (25,6) NULL,
   TaskNumber3                               decimal (25,6) NULL,
   TaskNumber4                               decimal (25,6) NULL,
   TaskNumber5                               decimal (25,6) NULL,
   TaskNumber6                               decimal (25,6) NULL,
   TaskNumber7                               decimal (25,6) NULL,
   TaskNumber8                               decimal (25,6) NULL,
   TaskNumber9                               decimal (25,6) NULL,
   TaskNumber10                              decimal (25,6) NULL,
   TaskNumber11                              decimal (25,6) NULL,
   TaskNumber12                              decimal (25,6) NULL,
   TaskNumber13                              decimal (25,6) NULL,
   TaskNumber14                              decimal (25,6) NULL,
   TaskNumber15                              decimal (25,6) NULL,
   TaskNumber16                              decimal (25,6) NULL,
   TaskNumber17                              decimal (25,6) NULL,
   TaskNumber18                              decimal (25,6) NULL,
   TaskNumber19                              decimal (25,6) NULL,
   TaskNumber20                              decimal (25,6) NULL,
   TaskNumber1Indicator                      smallint NULL,
   TaskNumber2Indicator                      smallint NULL,
   TaskNumber3Indicator                      smallint NULL,
   TaskNumber4Indicator                      smallint NULL,
   TaskNumber5Indicator                      smallint NULL,
   TaskNumber6Indicator                      smallint NULL,
   TaskNumber7Indicator                      smallint NULL,
   TaskNumber8Indicator                      smallint NULL,
   TaskNumber9Indicator                      smallint NULL,
   TaskNumber10Indicator                     smallint NULL,
   TaskNumber11Indicator                     smallint NULL,
   TaskNumber12Indicator                     smallint NULL,
   TaskNumber13Indicator                     smallint NULL,
   TaskNumber14Indicator                     smallint NULL,
   TaskNumber15Indicator                     smallint NULL,
   TaskNumber16Indicator                     smallint NULL,
   TaskNumber17Indicator                     smallint NULL,
   TaskNumber18Indicator                     smallint NULL,
   TaskNumber19Indicator                     smallint NULL,
   TaskNumber20Indicator                     smallint NULL,
   TaskOutlineCode1                          ntext NULL,
   TaskOutlineCode2                          ntext NULL,
   TaskOutlineCode3                          ntext NULL,
   TaskOutlineCode4                          ntext NULL,
   TaskOutlineCode5                          ntext NULL,
   TaskOutlineCode6                          ntext NULL,
   TaskOutlineCode7                          ntext NULL,
   TaskOutlineCode8                          ntext NULL,
   TaskOutlineCode9                          ntext NULL,
   TaskOutlineCode10                         ntext NULL,
   TaskStart1                                datetime NULL,
   TaskStart2                                datetime NULL,
   TaskStart3                                datetime NULL,
   TaskStart4                                datetime NULL,
   TaskStart5                                datetime NULL,
   TaskStart6                                datetime NULL,
   TaskStart7                                datetime NULL,
   TaskStart8                                datetime NULL,
   TaskStart9                                datetime NULL,
   TaskStart10                               datetime NULL,
   TaskStart1Indicator                       smallint NULL,
   TaskStart2Indicator                       smallint NULL,
   TaskStart3Indicator                       smallint NULL,
   TaskStart4Indicator                       smallint NULL,
   TaskStart5Indicator                       smallint NULL,
   TaskStart6Indicator                       smallint NULL,
   TaskStart7Indicator                       smallint NULL,
   TaskStart8Indicator                       smallint NULL,
   TaskStart9Indicator                       smallint NULL,
   TaskStart10Indicator                      smallint NULL,
   TaskText1                                 ntext NULL,
   TaskText2                                 ntext NULL,
   TaskText3                                 ntext NULL,
   TaskText4                                 ntext NULL,
   TaskText5                                 ntext NULL,
   TaskText6                                 ntext NULL,
   TaskText7                                 ntext NULL,
   TaskText8                                 ntext NULL,
   TaskText9                                 ntext NULL,
   TaskText10                                ntext NULL,
   TaskText11                                ntext NULL,
   TaskText12                                ntext NULL,
   TaskText13                                ntext NULL,
   TaskText14                                ntext NULL,
   TaskText15                                ntext NULL,
   TaskText16                                ntext NULL,
   TaskText17                                ntext NULL,
   TaskText18                                ntext NULL,
   TaskText19                                ntext NULL,
   TaskText20                                ntext NULL,
   TaskText21                                ntext NULL,
   TaskText22                                ntext NULL,
   TaskText23                                ntext NULL,
   TaskText24                                ntext NULL,
   TaskText25                                ntext NULL,
   TaskText26                                ntext NULL,
   TaskText27                                ntext NULL,
   TaskText28                                ntext NULL,
   TaskText29                                ntext NULL,
   TaskText30                                ntext NULL,
   TaskText1Indicator                        smallint NULL,
   TaskText2Indicator                        smallint NULL,
   TaskText3Indicator                        smallint NULL,
   TaskText4Indicator                        smallint NULL,
   TaskText5Indicator                        smallint NULL,
   TaskText6Indicator                        smallint NULL,
   TaskText7Indicator                        smallint NULL,
   TaskText8Indicator                        smallint NULL,
   TaskText9Indicator                        smallint NULL,
   TaskText10Indicator                       smallint NULL,
   TaskText11Indicator                       smallint NULL,
   TaskText12Indicator                       smallint NULL,
   TaskText13Indicator                       smallint NULL,
   TaskText14Indicator                       smallint NULL,
   TaskText15Indicator                       smallint NULL,
   TaskText16Indicator                       smallint NULL,
   TaskText17Indicator                       smallint NULL,
   TaskText18Indicator                       smallint NULL,
   TaskText19Indicator                       smallint NULL,
   TaskText20Indicator                       smallint NULL,
   TaskText21Indicator                       smallint NULL,
   TaskText22Indicator                       smallint NULL,
   TaskText23Indicator                       smallint NULL,
   TaskText24Indicator                       smallint NULL,
   TaskText25Indicator                       smallint NULL,
   TaskText26Indicator                       smallint NULL,
   TaskText27Indicator                       smallint NULL,
   TaskText28Indicator                       smallint NULL,
   TaskText29Indicator                       smallint NULL,
   TaskText30Indicator                       smallint NULL,
   CONSTRAINT PK_MSP_VIEW_PROJ_TASKS_CF_WPROJ_ID_CF_TaskUniqueID PRIMARY KEY CLUSTERED (WPROJ_ID, CF_TaskUniqueID)
)
GO

CREATE INDEX I_VIEW_TASKS_CF_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASKS_CF(CF_ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_TASKS_ENT
(
   WPROJ_ID                                  int NOT NULL,
   ENT_ProjectUniqueID                       int NOT NULL,
   ENT_TaskUniqueID                          int NOT NULL,
   TaskEnterpriseCost1                       decimal (25,6) NULL,
   TaskEnterpriseCost2                       decimal (25,6) NULL,
   TaskEnterpriseCost3                       decimal (25,6) NULL,
   TaskEnterpriseCost4                       decimal (25,6) NULL,
   TaskEnterpriseCost5                       decimal (25,6) NULL,
   TaskEnterpriseCost6                       decimal (25,6) NULL,
   TaskEnterpriseCost7                       decimal (25,6) NULL,
   TaskEnterpriseCost8                       decimal (25,6) NULL,
   TaskEnterpriseCost9                       decimal (25,6) NULL,
   TaskEnterpriseCost10                      decimal (25,6) NULL,
   TaskEnterpriseCost1Indicator              smallint NULL,
   TaskEnterpriseCost2Indicator              smallint NULL,
   TaskEnterpriseCost3Indicator              smallint NULL,
   TaskEnterpriseCost4Indicator              smallint NULL,
   TaskEnterpriseCost5Indicator              smallint NULL,
   TaskEnterpriseCost6Indicator              smallint NULL,
   TaskEnterpriseCost7Indicator              smallint NULL,
   TaskEnterpriseCost8Indicator              smallint NULL,
   TaskEnterpriseCost9Indicator              smallint NULL,
   TaskEnterpriseCost10Indicator             smallint NULL,
   TaskEnterpriseDate1                       datetime NULL,
   TaskEnterpriseDate2                       datetime NULL,
   TaskEnterpriseDate3                       datetime NULL,
   TaskEnterpriseDate4                       datetime NULL,
   TaskEnterpriseDate5                       datetime NULL,
   TaskEnterpriseDate6                       datetime NULL,
   TaskEnterpriseDate7                       datetime NULL,
   TaskEnterpriseDate8                       datetime NULL,
   TaskEnterpriseDate9                       datetime NULL,
   TaskEnterpriseDate10                      datetime NULL,
   TaskEnterpriseDate11                      datetime NULL,
   TaskEnterpriseDate12                      datetime NULL,
   TaskEnterpriseDate13                      datetime NULL,
   TaskEnterpriseDate14                      datetime NULL,
   TaskEnterpriseDate15                      datetime NULL,
   TaskEnterpriseDate16                      datetime NULL,
   TaskEnterpriseDate17                      datetime NULL,
   TaskEnterpriseDate18                      datetime NULL,
   TaskEnterpriseDate19                      datetime NULL,
   TaskEnterpriseDate20                      datetime NULL,
   TaskEnterpriseDate21                      datetime NULL,
   TaskEnterpriseDate22                      datetime NULL,
   TaskEnterpriseDate23                      datetime NULL,
   TaskEnterpriseDate24                      datetime NULL,
   TaskEnterpriseDate25                      datetime NULL,
   TaskEnterpriseDate26                      datetime NULL,
   TaskEnterpriseDate27                      datetime NULL,
   TaskEnterpriseDate28                      datetime NULL,
   TaskEnterpriseDate29                      datetime NULL,
   TaskEnterpriseDate30                      datetime NULL,
   TaskEnterpriseDate1Indicator              smallint NULL,
   TaskEnterpriseDate2Indicator              smallint NULL,
   TaskEnterpriseDate3Indicator              smallint NULL,
   TaskEnterpriseDate4Indicator              smallint NULL,
   TaskEnterpriseDate5Indicator              smallint NULL,
   TaskEnterpriseDate6Indicator              smallint NULL,
   TaskEnterpriseDate7Indicator              smallint NULL,
   TaskEnterpriseDate8Indicator              smallint NULL,
   TaskEnterpriseDate9Indicator              smallint NULL,
   TaskEnterpriseDate10Indicator             smallint NULL,
   TaskEnterpriseDate11Indicator             smallint NULL,
   TaskEnterpriseDate12Indicator             smallint NULL,
   TaskEnterpriseDate13Indicator             smallint NULL,
   TaskEnterpriseDate14Indicator             smallint NULL,
   TaskEnterpriseDate15Indicator             smallint NULL,
   TaskEnterpriseDate16Indicator             smallint NULL,
   TaskEnterpriseDate17Indicator             smallint NULL,
   TaskEnterpriseDate18Indicator             smallint NULL,
   TaskEnterpriseDate19Indicator             smallint NULL,
   TaskEnterpriseDate20Indicator             smallint NULL,
   TaskEnterpriseDate21Indicator             smallint NULL,
   TaskEnterpriseDate22Indicator             smallint NULL,
   TaskEnterpriseDate23Indicator             smallint NULL,
   TaskEnterpriseDate24Indicator             smallint NULL,
   TaskEnterpriseDate25Indicator             smallint NULL,
   TaskEnterpriseDate26Indicator             smallint NULL,
   TaskEnterpriseDate27Indicator             smallint NULL,
   TaskEnterpriseDate28Indicator             smallint NULL,
   TaskEnterpriseDate29Indicator             smallint NULL,
   TaskEnterpriseDate30Indicator             smallint NULL,
   TaskEnterpriseDuration1                   int NULL,
   TaskEnterpriseDuration2                   int NULL,
   TaskEnterpriseDuration3                   int NULL,
   TaskEnterpriseDuration4                   int NULL,
   TaskEnterpriseDuration5                   int NULL,
   TaskEnterpriseDuration6                   int NULL,
   TaskEnterpriseDuration7                   int NULL,
   TaskEnterpriseDuration8                   int NULL,
   TaskEnterpriseDuration9                   int NULL,
   TaskEnterpriseDuration10                  int NULL,
   TaskEnterpriseDuration1Indicator          smallint NULL,
   TaskEnterpriseDuration2Indicator          smallint NULL,
   TaskEnterpriseDuration3Indicator          smallint NULL,
   TaskEnterpriseDuration4Indicator          smallint NULL,
   TaskEnterpriseDuration5Indicator          smallint NULL,
   TaskEnterpriseDuration6Indicator          smallint NULL,
   TaskEnterpriseDuration7Indicator          smallint NULL,
   TaskEnterpriseDuration8Indicator          smallint NULL,
   TaskEnterpriseDuration9Indicator          smallint NULL,
   TaskEnterpriseDuration10Indicator         smallint NULL,
   TaskEnterpriseFlag1                       tinyint NULL,
   TaskEnterpriseFlag2                       tinyint NULL,
   TaskEnterpriseFlag3                       tinyint NULL,
   TaskEnterpriseFlag4                       tinyint NULL,
   TaskEnterpriseFlag5                       tinyint NULL,
   TaskEnterpriseFlag6                       tinyint NULL,
   TaskEnterpriseFlag7                       tinyint NULL,
   TaskEnterpriseFlag8                       tinyint NULL,
   TaskEnterpriseFlag9                       tinyint NULL,
   TaskEnterpriseFlag10                      tinyint NULL,
   TaskEnterpriseFlag11                      tinyint NULL,
   TaskEnterpriseFlag12                      tinyint NULL,
   TaskEnterpriseFlag13                      tinyint NULL,
   TaskEnterpriseFlag14                      tinyint NULL,
   TaskEnterpriseFlag15                      tinyint NULL,
   TaskEnterpriseFlag16                      tinyint NULL,
   TaskEnterpriseFlag17                      tinyint NULL,
   TaskEnterpriseFlag18                      tinyint NULL,
   TaskEnterpriseFlag19                      tinyint NULL,
   TaskEnterpriseFlag20                      tinyint NULL,
   TaskEnterpriseFlag1Indicator              smallint NULL,
   TaskEnterpriseFlag2Indicator              smallint NULL,
   TaskEnterpriseFlag3Indicator              smallint NULL,
   TaskEnterpriseFlag4Indicator              smallint NULL,
   TaskEnterpriseFlag5Indicator              smallint NULL,
   TaskEnterpriseFlag6Indicator              smallint NULL,
   TaskEnterpriseFlag7Indicator              smallint NULL,
   TaskEnterpriseFlag8Indicator              smallint NULL,
   TaskEnterpriseFlag9Indicator              smallint NULL,
   TaskEnterpriseFlag10Indicator             smallint NULL,
   TaskEnterpriseFlag11Indicator             smallint NULL,
   TaskEnterpriseFlag12Indicator             smallint NULL,
   TaskEnterpriseFlag13Indicator             smallint NULL,
   TaskEnterpriseFlag14Indicator             smallint NULL,
   TaskEnterpriseFlag15Indicator             smallint NULL,
   TaskEnterpriseFlag16Indicator             smallint NULL,
   TaskEnterpriseFlag17Indicator             smallint NULL,
   TaskEnterpriseFlag18Indicator             smallint NULL,
   TaskEnterpriseFlag19Indicator             smallint NULL,
   TaskEnterpriseFlag20Indicator             smallint NULL,
   TaskEnterpriseNumber1                     decimal (25,6) NULL,
   TaskEnterpriseNumber2                     decimal (25,6) NULL,
   TaskEnterpriseNumber3                     decimal (25,6) NULL,
   TaskEnterpriseNumber4                     decimal (25,6) NULL,
   TaskEnterpriseNumber5                     decimal (25,6) NULL,
   TaskEnterpriseNumber6                     decimal (25,6) NULL,
   TaskEnterpriseNumber7                     decimal (25,6) NULL,
   TaskEnterpriseNumber8                     decimal (25,6) NULL,
   TaskEnterpriseNumber9                     decimal (25,6) NULL,
   TaskEnterpriseNumber10                    decimal (25,6) NULL,
   TaskEnterpriseNumber11                    decimal (25,6) NULL,
   TaskEnterpriseNumber12                    decimal (25,6) NULL,
   TaskEnterpriseNumber13                    decimal (25,6) NULL,
   TaskEnterpriseNumber14                    decimal (25,6) NULL,
   TaskEnterpriseNumber15                    decimal (25,6) NULL,
   TaskEnterpriseNumber16                    decimal (25,6) NULL,
   TaskEnterpriseNumber17                    decimal (25,6) NULL,
   TaskEnterpriseNumber18                    decimal (25,6) NULL,
   TaskEnterpriseNumber19                    decimal (25,6) NULL,
   TaskEnterpriseNumber20                    decimal (25,6) NULL,
   TaskEnterpriseNumber21                    decimal (25,6) NULL,
   TaskEnterpriseNumber22                    decimal (25,6) NULL,
   TaskEnterpriseNumber23                    decimal (25,6) NULL,
   TaskEnterpriseNumber24                    decimal (25,6) NULL,
   TaskEnterpriseNumber25                    decimal (25,6) NULL,
   TaskEnterpriseNumber26                    decimal (25,6) NULL,
   TaskEnterpriseNumber27                    decimal (25,6) NULL,
   TaskEnterpriseNumber28                    decimal (25,6) NULL,
   TaskEnterpriseNumber29                    decimal (25,6) NULL,
   TaskEnterpriseNumber30                    decimal (25,6) NULL,
   TaskEnterpriseNumber31                    decimal (25,6) NULL,
   TaskEnterpriseNumber32                    decimal (25,6) NULL,
   TaskEnterpriseNumber33                    decimal (25,6) NULL,
   TaskEnterpriseNumber34                    decimal (25,6) NULL,
   TaskEnterpriseNumber35                    decimal (25,6) NULL,
   TaskEnterpriseNumber36                    decimal (25,6) NULL,
   TaskEnterpriseNumber37                    decimal (25,6) NULL,
   TaskEnterpriseNumber38                    decimal (25,6) NULL,
   TaskEnterpriseNumber39                    decimal (25,6) NULL,
   TaskEnterpriseNumber40                    decimal (25,6) NULL,
   TaskEnterpriseNumber1Indicator            smallint NULL,
   TaskEnterpriseNumber2Indicator            smallint NULL,
   TaskEnterpriseNumber3Indicator            smallint NULL,
   TaskEnterpriseNumber4Indicator            smallint NULL,
   TaskEnterpriseNumber5Indicator            smallint NULL,
   TaskEnterpriseNumber6Indicator            smallint NULL,
   TaskEnterpriseNumber7Indicator            smallint NULL,
   TaskEnterpriseNumber8Indicator            smallint NULL,
   TaskEnterpriseNumber9Indicator            smallint NULL,
   TaskEnterpriseNumber10Indicator           smallint NULL,
   TaskEnterpriseNumber11Indicator           smallint NULL,
   TaskEnterpriseNumber12Indicator           smallint NULL,
   TaskEnterpriseNumber13Indicator           smallint NULL,
   TaskEnterpriseNumber14Indicator           smallint NULL,
   TaskEnterpriseNumber15Indicator           smallint NULL,
   TaskEnterpriseNumber16Indicator           smallint NULL,
   TaskEnterpriseNumber17Indicator           smallint NULL,
   TaskEnterpriseNumber18Indicator           smallint NULL,
   TaskEnterpriseNumber19Indicator           smallint NULL,
   TaskEnterpriseNumber20Indicator           smallint NULL,
   TaskEnterpriseNumber21Indicator           smallint NULL,
   TaskEnterpriseNumber22Indicator           smallint NULL,
   TaskEnterpriseNumber23Indicator           smallint NULL,
   TaskEnterpriseNumber24Indicator           smallint NULL,
   TaskEnterpriseNumber25Indicator           smallint NULL,
   TaskEnterpriseNumber26Indicator           smallint NULL,
   TaskEnterpriseNumber27Indicator           smallint NULL,
   TaskEnterpriseNumber28Indicator           smallint NULL,
   TaskEnterpriseNumber29Indicator           smallint NULL,
   TaskEnterpriseNumber30Indicator           smallint NULL,
   TaskEnterpriseNumber31Indicator           smallint NULL,
   TaskEnterpriseNumber32Indicator           smallint NULL,
   TaskEnterpriseNumber33Indicator           smallint NULL,
   TaskEnterpriseNumber34Indicator           smallint NULL,
   TaskEnterpriseNumber35Indicator           smallint NULL,
   TaskEnterpriseNumber36Indicator           smallint NULL,
   TaskEnterpriseNumber37Indicator           smallint NULL,
   TaskEnterpriseNumber38Indicator           smallint NULL,
   TaskEnterpriseNumber39Indicator           smallint NULL,
   TaskEnterpriseNumber40Indicator           smallint NULL,
   TaskEnterpriseOutlineCode1ID              integer NULL,
   TaskEnterpriseOutlineCode2ID              integer NULL,
   TaskEnterpriseOutlineCode3ID              integer NULL,
   TaskEnterpriseOutlineCode4ID              integer NULL,
   TaskEnterpriseOutlineCode5ID              integer NULL,
   TaskEnterpriseOutlineCode6ID              integer NULL,
   TaskEnterpriseOutlineCode7ID              integer NULL,
   TaskEnterpriseOutlineCode8ID              integer NULL,
   TaskEnterpriseOutlineCode9ID              integer NULL,
   TaskEnterpriseOutlineCode10ID             integer NULL,
   TaskEnterpriseOutlineCode11ID             integer NULL,
   TaskEnterpriseOutlineCode12ID             integer NULL,
   TaskEnterpriseOutlineCode13ID             integer NULL,
   TaskEnterpriseOutlineCode14ID             integer NULL,
   TaskEnterpriseOutlineCode15ID             integer NULL,
   TaskEnterpriseOutlineCode16ID             integer NULL,
   TaskEnterpriseOutlineCode17ID             integer NULL,
   TaskEnterpriseOutlineCode18ID             integer NULL,
   TaskEnterpriseOutlineCode19ID             integer NULL,
   TaskEnterpriseOutlineCode20ID             integer NULL,
   TaskEnterpriseOutlineCode21ID             integer NULL,
   TaskEnterpriseOutlineCode22ID             integer NULL,
   TaskEnterpriseOutlineCode23ID             integer NULL,
   TaskEnterpriseOutlineCode24ID             integer NULL,
   TaskEnterpriseOutlineCode25ID             integer NULL,
   TaskEnterpriseOutlineCode26ID             integer NULL,
   TaskEnterpriseOutlineCode27ID             integer NULL,
   TaskEnterpriseOutlineCode28ID             integer NULL,
   TaskEnterpriseOutlineCode29ID             integer NULL,
   TaskEnterpriseOutlineCode30ID             integer NULL,
   TaskEnterpriseText1                       ntext NULL,
   TaskEnterpriseText2                       ntext NULL,
   TaskEnterpriseText3                       ntext NULL,
   TaskEnterpriseText4                       ntext NULL,
   TaskEnterpriseText5                       ntext NULL,
   TaskEnterpriseText6                       ntext NULL,
   TaskEnterpriseText7                       ntext NULL,
   TaskEnterpriseText8                       ntext NULL,
   TaskEnterpriseText9                       ntext NULL,
   TaskEnterpriseText10                      ntext NULL,
   TaskEnterpriseText11                      ntext NULL,
   TaskEnterpriseText12                      ntext NULL,
   TaskEnterpriseText13                      ntext NULL,
   TaskEnterpriseText14                      ntext NULL,
   TaskEnterpriseText15                      ntext NULL,
   TaskEnterpriseText16                      ntext NULL,
   TaskEnterpriseText17                      ntext NULL,
   TaskEnterpriseText18                      ntext NULL,
   TaskEnterpriseText19                      ntext NULL,
   TaskEnterpriseText20                      ntext NULL,
   TaskEnterpriseText21                      ntext NULL,
   TaskEnterpriseText22                      ntext NULL,
   TaskEnterpriseText23                      ntext NULL,
   TaskEnterpriseText24                      ntext NULL,
   TaskEnterpriseText25                      ntext NULL,
   TaskEnterpriseText26                      ntext NULL,
   TaskEnterpriseText27                      ntext NULL,
   TaskEnterpriseText28                      ntext NULL,
   TaskEnterpriseText29                      ntext NULL,
   TaskEnterpriseText30                      ntext NULL,
   TaskEnterpriseText31                      ntext NULL,
   TaskEnterpriseText32                      ntext NULL,
   TaskEnterpriseText33                      ntext NULL,
   TaskEnterpriseText34                      ntext NULL,
   TaskEnterpriseText35                      ntext NULL,
   TaskEnterpriseText36                      ntext NULL,
   TaskEnterpriseText37                      ntext NULL,
   TaskEnterpriseText38                      ntext NULL,
   TaskEnterpriseText39                      ntext NULL,
   TaskEnterpriseText40                      ntext NULL,
   TaskEnterpriseText1Indicator              smallint NULL,
   TaskEnterpriseText2Indicator              smallint NULL,
   TaskEnterpriseText3Indicator              smallint NULL,
   TaskEnterpriseText4Indicator              smallint NULL,
   TaskEnterpriseText5Indicator              smallint NULL,
   TaskEnterpriseText6Indicator              smallint NULL,
   TaskEnterpriseText7Indicator              smallint NULL,
   TaskEnterpriseText8Indicator              smallint NULL,
   TaskEnterpriseText9Indicator              smallint NULL,
   TaskEnterpriseText10Indicator             smallint NULL,
   TaskEnterpriseText11Indicator             smallint NULL,
   TaskEnterpriseText12Indicator             smallint NULL,
   TaskEnterpriseText13Indicator             smallint NULL,
   TaskEnterpriseText14Indicator             smallint NULL,
   TaskEnterpriseText15Indicator             smallint NULL,
   TaskEnterpriseText16Indicator             smallint NULL,
   TaskEnterpriseText17Indicator             smallint NULL,
   TaskEnterpriseText18Indicator             smallint NULL,
   TaskEnterpriseText19Indicator             smallint NULL,
   TaskEnterpriseText20Indicator             smallint NULL,
   TaskEnterpriseText21Indicator             smallint NULL,
   TaskEnterpriseText22Indicator             smallint NULL,
   TaskEnterpriseText23Indicator             smallint NULL,
   TaskEnterpriseText24Indicator             smallint NULL,
   TaskEnterpriseText25Indicator             smallint NULL,
   TaskEnterpriseText26Indicator             smallint NULL,
   TaskEnterpriseText27Indicator             smallint NULL,
   TaskEnterpriseText28Indicator             smallint NULL,
   TaskEnterpriseText29Indicator             smallint NULL,
   TaskEnterpriseText30Indicator             smallint NULL,
   TaskEnterpriseText31Indicator             smallint NULL,
   TaskEnterpriseText32Indicator             smallint NULL,
   TaskEnterpriseText33Indicator             smallint NULL,
   TaskEnterpriseText34Indicator             smallint NULL,
   TaskEnterpriseText35Indicator             smallint NULL,
   TaskEnterpriseText36Indicator             smallint NULL,
   TaskEnterpriseText37Indicator             smallint NULL,
   TaskEnterpriseText38Indicator             smallint NULL,
   TaskEnterpriseText39Indicator             smallint NULL,
   TaskEnterpriseText40Indicator             smallint NULL,
   CONSTRAINT PK_MSP_VIEW_PROJ_TASKS_ENT_WPROJ_ID_ENT_TaskUniqueID PRIMARY KEY CLUSTERED(WPROJ_ID, ENT_TaskUniqueID) 
)
GO

CREATE INDEX I_VIEW_TASKS_ENT_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASKS_ENT(ENT_ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_RES_STD
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   ResourceUniqueID                          int NOT NULL,
   ResourceEnterpriseUniqueID                int NULL,
   ResourceBaseline1Cost                     decimal (25,6) NULL,
   ResourceBaseline2Cost                     decimal (25,6) NULL,
   ResourceBaseline3Cost                     decimal (25,6) NULL,
   ResourceBaseline4Cost                     decimal (25,6) NULL,
   ResourceBaseline5Cost                     decimal (25,6) NULL,
   ResourceBaseline6Cost                     decimal (25,6) NULL,
   ResourceBaseline7Cost                     decimal (25,6) NULL,
   ResourceBaseline8Cost                     decimal (25,6) NULL,
   ResourceBaseline9Cost                     decimal (25,6) NULL,
   ResourceBaseline10Cost                    decimal (25,6) NULL,
   ResourceBaselineFinish                    datetime NULL,
   ResourceBaseline1Finish                   datetime NULL,
   ResourceBaseline2Finish                   datetime NULL,
   ResourceBaseline3Finish                   datetime NULL,
   ResourceBaseline4Finish                   datetime NULL,
   ResourceBaseline5Finish                   datetime NULL,
   ResourceBaseline6Finish                   datetime NULL,
   ResourceBaseline7Finish                   datetime NULL,
   ResourceBaseline8Finish                   datetime NULL,
   ResourceBaseline9Finish                   datetime NULL,
   ResourceBaseline10Finish                  datetime NULL,
   ResourceBaselineStart                     datetime NULL,
   ResourceBaseline1Start                    datetime NULL,
   ResourceBaseline2Start                    datetime NULL,
   ResourceBaseline3Start                    datetime NULL,
   ResourceBaseline4Start                    datetime NULL,
   ResourceBaseline5Start                    datetime NULL,
   ResourceBaseline6Start                    datetime NULL,
   ResourceBaseline7Start                    datetime NULL,
   ResourceBaseline8Start                    datetime NULL,
   ResourceBaseline9Start                    datetime NULL,
   ResourceBaseline10Start                   datetime NULL,
   ResourceBaseline1Work                     decimal (25,6) NULL,
   ResourceBaseline2Work                     decimal (25,6) NULL,
   ResourceBaseline3Work                     decimal (25,6) NULL,
   ResourceBaseline4Work                     decimal (25,6) NULL,
   ResourceBaseline5Work                     decimal (25,6) NULL,
   ResourceBaseline6Work                     decimal (25,6) NULL,
   ResourceBaseline7Work                     decimal (25,6) NULL,
   ResourceBaseline8Work                     decimal (25,6) NULL,
   ResourceBaseline9Work                     decimal (25,6) NULL,
   ResourceBaseline10Work                    decimal (25,6) NULL,
   ResourcePercentWorkComplete               smallint NULL,
   ResourceAccrueAt                          smallint NULL,
   ResourceActualCost                        decimal (25,6) NULL,
   ResourceActualOvertimeCost                decimal (25,6) NULL,
   ResourceActualOvertimeWork                decimal (25,6) NULL,
   ResourceActualWork                        decimal (25,6) NULL,
   ResourceACWP                              decimal (25,6) NULL,
   ResourceAvailableFrom                     datetime NULL,
   ResourceAvailableTo                       datetime NULL,
   ResourceBaseCalendar                      ntext NULL,
   ResourceBaselineCost                      decimal (25,6) NULL,
   ResourceBaselineWork                      decimal (25,6) NULL,
   ResourceBCWP                              decimal (25,6) NULL,
   ResourceBCWS                              decimal (25,6) NULL,
   ResourceCanLevel                          tinyint NULL,
   ResourceCode                              ntext NULL,
   ResourceConfirmed                         tinyint NULL,
   ResourceCost                              decimal (25,6) NULL,
   ResourceCostPerUse                        decimal (25,6) NULL,
   ResourceCostVariance                      decimal (25,6) NULL,
   ResourceCV                                decimal (25,6) NULL,
   ResourceEmailAddress                      ntext NULL,
   ResourceFinish                            datetime NULL,
   ResourceGroup                             ntext NULL,
   ResourceHyperlink                         ntext NULL,
   ResourceHyperlinkAddress                  ntext NULL,
   ResourceHyperlinkHref                     ntext NULL,
   ResourceHyperlinkScreenTip                ntext NULL,
   ResourceHyperlinkSubAddress               ntext NULL,
   ResourceID                                int NULL,
   ResourceInitials                          ntext NULL,
   ResourceIsNull                            tinyint NULL,
   ResourceLinkedFields                      tinyint NULL,
   ResourceMaterialLabel                     ntext NULL,
   ResourceMaxUnits                          decimal (25,6) NULL,
   ResourceName                              nvarchar (255) NULL,
   ResourceNotes                             ntext NULL,
   ResourceNTAccount                         ntext NULL,
   ResourceObjects                           int NULL,
   ResourceOverallocated                     tinyint NULL,
   ResourceOvertimeCost                      decimal (25,6) NULL,
   ResourceOvertimeRate                      decimal (25,6) NULL,
   ResourceOvertimeWork                      decimal (25,6) NULL,
   ResourcePeakUnits                         decimal (25,6) NULL,
   ResourcePhonetics                         ntext NULL,
   ResourceRegularWork                       decimal (25,6) NULL,
   ResourceRemainingCost                     decimal (25,6) NULL,
   ResourceRemainingOvertimeCost             decimal (25,6) NULL,
   ResourceRemainingOvertimeWork             decimal (25,6) NULL,
   ResourceRemainingWork                     decimal (25,6) NULL,
   ResourceResponsePending                   tinyint NULL,
   ResourceStandardRate                      decimal (25,6) NULL,
   ResourceStart                             datetime NULL,
   ResourceSV                                decimal (25,6) NULL,
   ResourceTeamStatusPending                 tinyint NULL,
   ResourceType                              smallint NULL,
   ResourceUpdateNeeded                      tinyint NULL,
   ResourceVAC                               decimal (25,6) NULL,
   ResourceWork                              decimal (25,6) NULL,
   ResourceWorkgroup                         smallint NULL,
   ResourceWorkVariance                      decimal (25,6) NULL,
   CONSTRAINT PK_MSP_VIEW_PROJ_RES_STD_WPROJ_ID_ResourceUniqueID PRIMARY KEY CLUSTERED(WPROJ_ID, ResourceUniqueID) 
)
GO

CREATE INDEX I_VIEW_RES_STD_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_STD(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_RES_CF
(
   WPROJ_ID                                  int NOT NULL,
   CF_ProjectUniqueID                        int NOT NULL,
   CF_ResourceUniqueID                       int NOT NULL,
   CF_ResourceEnterpriseUniqueID             int NULL,
   ResourceCost1                             decimal (25,6) NULL,
   ResourceCost2                             decimal (25,6) NULL,
   ResourceCost3                             decimal (25,6) NULL,
   ResourceCost4                             decimal (25,6) NULL,
   ResourceCost5                             decimal (25,6) NULL,
   ResourceCost6                             decimal (25,6) NULL,
   ResourceCost7                             decimal (25,6) NULL,
   ResourceCost8                             decimal (25,6) NULL,
   ResourceCost9                             decimal (25,6) NULL,
   ResourceCost10                            decimal (25,6) NULL,
   ResourceCost1Indicator                    smallint NULL,
   ResourceCost2Indicator                    smallint NULL,
   ResourceCost3Indicator                    smallint NULL,
   ResourceCost4Indicator                    smallint NULL,
   ResourceCost5Indicator                    smallint NULL,
   ResourceCost6Indicator                    smallint NULL,
   ResourceCost7Indicator                    smallint NULL,
   ResourceCost8Indicator                    smallint NULL,
   ResourceCost9Indicator                    smallint NULL,
   ResourceCost10Indicator                   smallint NULL,
   ResourceDate1                             datetime NULL,
   ResourceDate2                             datetime NULL,
   ResourceDate3                             datetime NULL,
   ResourceDate4                             datetime NULL,
   ResourceDate5                             datetime NULL,
   ResourceDate6                             datetime NULL,
   ResourceDate7                             datetime NULL,
   ResourceDate8                             datetime NULL,
   ResourceDate9                             datetime NULL,
   ResourceDate10                            datetime NULL,
   ResourceDate1Indicator                    smallint NULL,
   ResourceDate2Indicator                    smallint NULL,
   ResourceDate3Indicator                    smallint NULL,
   ResourceDate4Indicator                    smallint NULL,
   ResourceDate5Indicator                    smallint NULL,
   ResourceDate6Indicator                    smallint NULL,
   ResourceDate7Indicator                    smallint NULL,
   ResourceDate8Indicator                    smallint NULL,
   ResourceDate9Indicator                    smallint NULL,
   ResourceDate10Indicator                   smallint NULL,
   ResourceDuration1                         int NULL,
   ResourceDuration2                         int NULL,
   ResourceDuration3                         int NULL,
   ResourceDuration4                         int NULL,
   ResourceDuration5                         int NULL,
   ResourceDuration6                         int NULL,
   ResourceDuration7                         int NULL,
   ResourceDuration8                         int NULL,
   ResourceDuration9                         int NULL,
   ResourceDuration10                        int NULL,
   ResourceDuration1Indicator                smallint NULL,
   ResourceDuration2Indicator                smallint NULL,
   ResourceDuration3Indicator                smallint NULL,
   ResourceDuration4Indicator                smallint NULL,
   ResourceDuration5Indicator                smallint NULL,
   ResourceDuration6Indicator                smallint NULL,
   ResourceDuration7Indicator                smallint NULL,
   ResourceDuration8Indicator                smallint NULL,
   ResourceDuration9Indicator                smallint NULL,
   ResourceDuration10Indicator               smallint NULL,
   ResourceFinish1                           datetime NULL,
   ResourceFinish2                           datetime NULL,
   ResourceFinish3                           datetime NULL,
   ResourceFinish4                           datetime NULL,
   ResourceFinish5                           datetime NULL,
   ResourceFinish6                           datetime NULL,
   ResourceFinish7                           datetime NULL,
   ResourceFinish8                           datetime NULL,
   ResourceFinish9                           datetime NULL,
   ResourceFinish10                          datetime NULL,
   ResourceFinish1Indicator                  smallint NULL,
   ResourceFinish2Indicator                  smallint NULL,
   ResourceFinish3Indicator                  smallint NULL,
   ResourceFinish4Indicator                  smallint NULL,
   ResourceFinish5Indicator                  smallint NULL,
   ResourceFinish6Indicator                  smallint NULL,
   ResourceFinish7Indicator                  smallint NULL,
   ResourceFinish8Indicator                  smallint NULL,
   ResourceFinish9Indicator                  smallint NULL,
   ResourceFinish10Indicator                 smallint NULL,
   ResourceFlag1                             tinyint NULL,
   ResourceFlag2                             tinyint NULL,
   ResourceFlag3                             tinyint NULL,
   ResourceFlag4                             tinyint NULL,
   ResourceFlag5                             tinyint NULL,
   ResourceFlag6                             tinyint NULL,
   ResourceFlag7                             tinyint NULL,
   ResourceFlag8                             tinyint NULL,
   ResourceFlag9                             tinyint NULL,
   ResourceFlag10                            tinyint NULL,
   ResourceFlag11                            tinyint NULL,
   ResourceFlag12                            tinyint NULL,
   ResourceFlag13                            tinyint NULL,
   ResourceFlag14                            tinyint NULL,
   ResourceFlag15                            tinyint NULL,
   ResourceFlag16                            tinyint NULL,
   ResourceFlag17                            tinyint NULL,
   ResourceFlag18                            tinyint NULL,
   ResourceFlag19                            tinyint NULL,
   ResourceFlag20                            tinyint NULL,
   ResourceFlag1Indicator                    smallint NULL,
   ResourceFlag2Indicator                    smallint NULL,
   ResourceFlag3Indicator                    smallint NULL,
   ResourceFlag4Indicator                    smallint NULL,
   ResourceFlag5Indicator                    smallint NULL,
   ResourceFlag6Indicator                    smallint NULL,
   ResourceFlag7Indicator                    smallint NULL,
   ResourceFlag8Indicator                    smallint NULL,
   ResourceFlag9Indicator                    smallint NULL,
   ResourceFlag10Indicator                   smallint NULL,
   ResourceFlag11Indicator                   smallint NULL,
   ResourceFlag12Indicator                   smallint NULL,
   ResourceFlag13Indicator                   smallint NULL,
   ResourceFlag14Indicator                   smallint NULL,
   ResourceFlag15Indicator                   smallint NULL,
   ResourceFlag16Indicator                   smallint NULL,
   ResourceFlag17Indicator                   smallint NULL,
   ResourceFlag18Indicator                   smallint NULL,
   ResourceFlag19Indicator                   smallint NULL,
   ResourceFlag20Indicator                   smallint NULL,
   ResourceNumber1                           decimal (25,6) NULL,
   ResourceNumber2                           decimal (25,6) NULL,
   ResourceNumber3                           decimal (25,6) NULL,
   ResourceNumber4                           decimal (25,6) NULL,
   ResourceNumber5                           decimal (25,6) NULL,
   ResourceNumber6                           decimal (25,6) NULL,
   ResourceNumber7                           decimal (25,6) NULL,
   ResourceNumber8                           decimal (25,6) NULL,
   ResourceNumber9                           decimal (25,6) NULL,
   ResourceNumber10                          decimal (25,6) NULL,
   ResourceNumber11                          decimal (25,6) NULL,
   ResourceNumber12                          decimal (25,6) NULL,
   ResourceNumber13                          decimal (25,6) NULL,
   ResourceNumber14                          decimal (25,6) NULL,
   ResourceNumber15                          decimal (25,6) NULL,
   ResourceNumber16                          decimal (25,6) NULL,
   ResourceNumber17                          decimal (25,6) NULL,
   ResourceNumber18                          decimal (25,6) NULL,
   ResourceNumber19                          decimal (25,6) NULL,
   ResourceNumber20                          decimal (25,6) NULL,
   ResourceNumber1Indicator                  smallint NULL,
   ResourceNumber2Indicator                  smallint NULL,
   ResourceNumber3Indicator                  smallint NULL,
   ResourceNumber4Indicator                  smallint NULL,
   ResourceNumber5Indicator                  smallint NULL,
   ResourceNumber6Indicator                  smallint NULL,
   ResourceNumber7Indicator                  smallint NULL,
   ResourceNumber8Indicator                  smallint NULL,
   ResourceNumber9Indicator                  smallint NULL,
   ResourceNumber10Indicator                 smallint NULL,
   ResourceNumber11Indicator                 smallint NULL,
   ResourceNumber12Indicator                 smallint NULL,
   ResourceNumber13Indicator                 smallint NULL,
   ResourceNumber14Indicator                 smallint NULL,
   ResourceNumber15Indicator                 smallint NULL,
   ResourceNumber16Indicator                 smallint NULL,
   ResourceNumber17Indicator                 smallint NULL,
   ResourceNumber18Indicator                 smallint NULL,
   ResourceNumber19Indicator                 smallint NULL,
   ResourceNumber20Indicator                 smallint NULL,
   ResourceOutlineCode1                      ntext NULL,
   ResourceOutlineCode2                      ntext NULL,
   ResourceOutlineCode3                      ntext NULL,
   ResourceOutlineCode4                      ntext NULL,
   ResourceOutlineCode5                      ntext NULL,
   ResourceOutlineCode6                      ntext NULL,
   ResourceOutlineCode7                      ntext NULL,
   ResourceOutlineCode8                      ntext NULL,
   ResourceOutlineCode9                      ntext NULL,
   ResourceOutlineCode10                     ntext NULL,
   ResourceStart1                            datetime NULL,
   ResourceStart2                            datetime NULL,
   ResourceStart3                            datetime NULL,
   ResourceStart4                            datetime NULL,
   ResourceStart5                            datetime NULL,
   ResourceStart6                            datetime NULL,
   ResourceStart7                            datetime NULL,
   ResourceStart8                            datetime NULL,
   ResourceStart9                            datetime NULL,
   ResourceStart10                           datetime NULL,
   ResourceStart1Indicator                   smallint NULL,
   ResourceStart2Indicator                   smallint NULL,
   ResourceStart3Indicator                   smallint NULL,
   ResourceStart4Indicator                   smallint NULL,
   ResourceStart5Indicator                   smallint NULL,
   ResourceStart6Indicator                   smallint NULL,
   ResourceStart7Indicator                   smallint NULL,
   ResourceStart8Indicator                   smallint NULL,
   ResourceStart9Indicator                   smallint NULL,
   ResourceStart10Indicator                  smallint NULL,
   ResourceText1                             ntext NULL,
   ResourceText2                             ntext NULL,
   ResourceText3                             ntext NULL,
   ResourceText4                             ntext NULL,
   ResourceText5                             ntext NULL,
   ResourceText6                             ntext NULL,
   ResourceText7                             ntext NULL,
   ResourceText8                             ntext NULL,
   ResourceText9                             ntext NULL,
   ResourceText10                            ntext NULL,
   ResourceText11                            ntext NULL,
   ResourceText12                            ntext NULL,
   ResourceText13                            ntext NULL,
   ResourceText14                            ntext NULL,
   ResourceText15                            ntext NULL,
   ResourceText16                            ntext NULL,
   ResourceText17                            ntext NULL,
   ResourceText18                            ntext NULL,
   ResourceText19                            ntext NULL,
   ResourceText20                            ntext NULL,
   ResourceText21                            ntext NULL,
   ResourceText22                            ntext NULL,
   ResourceText23                            ntext NULL,
   ResourceText24                            ntext NULL,
   ResourceText25                            ntext NULL,
   ResourceText26                            ntext NULL,
   ResourceText27                            ntext NULL,
   ResourceText28                            ntext NULL,
   ResourceText29                            ntext NULL,
   ResourceText30                            ntext NULL,
   ResourceText1Indicator                    smallint NULL,
   ResourceText2Indicator                    smallint NULL,
   ResourceText3Indicator                    smallint NULL,
   ResourceText4Indicator                    smallint NULL,
   ResourceText5Indicator                    smallint NULL,
   ResourceText6Indicator                    smallint NULL,
   ResourceText7Indicator                    smallint NULL,
   ResourceText8Indicator                    smallint NULL,
   ResourceText9Indicator                    smallint NULL,
   ResourceText10Indicator                   smallint NULL,
   ResourceText11Indicator                   smallint NULL,
   ResourceText12Indicator                   smallint NULL,
   ResourceText13Indicator                   smallint NULL,
   ResourceText14Indicator                   smallint NULL,
   ResourceText15Indicator                   smallint NULL,
   ResourceText16Indicator                   smallint NULL,
   ResourceText17Indicator                   smallint NULL,
   ResourceText18Indicator                   smallint NULL,
   ResourceText19Indicator                   smallint NULL,
   ResourceText20Indicator                   smallint NULL,
   ResourceText21Indicator                   smallint NULL,
   ResourceText22Indicator                   smallint NULL,
   ResourceText23Indicator                   smallint NULL,
   ResourceText24Indicator                   smallint NULL,
   ResourceText25Indicator                   smallint NULL,
   ResourceText26Indicator                   smallint NULL,
   ResourceText27Indicator                   smallint NULL,
   ResourceText28Indicator                   smallint NULL,
   ResourceText29Indicator                   smallint NULL,
   ResourceText30Indicator                   smallint NULL,
   CONSTRAINT PK_MSP_VIEW_PROJ_RES_CF_WPROJ_ID_CF_ResourceUniqueID PRIMARY KEY CLUSTERED(WPROJ_ID, CF_ResourceUniqueID) 
)
GO


CREATE INDEX I_VIEW_RES_CF_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_CF(CF_ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_RES_ENT
(
   WPROJ_ID                                  int NOT NULL,
   ENT_ProjectUniqueID                       int NOT NULL,
   ENT_ResourceUniqueID                      int NOT NULL,
   ENT_ResourceEnterpriseUniqueID            int NULL,
   ResourceEnterpriseCost1                   decimal (25,6) NULL,
   ResourceEnterpriseCost2                   decimal (25,6) NULL,
   ResourceEnterpriseCost3                   decimal (25,6) NULL,
   ResourceEnterpriseCost4                   decimal (25,6) NULL,
   ResourceEnterpriseCost5                   decimal (25,6) NULL,
   ResourceEnterpriseCost6                   decimal (25,6) NULL,
   ResourceEnterpriseCost7                   decimal (25,6) NULL,
   ResourceEnterpriseCost8                   decimal (25,6) NULL,
   ResourceEnterpriseCost9                   decimal (25,6) NULL,
   ResourceEnterpriseCost10                  decimal (25,6) NULL,
   ResourceEnterpriseCost1Indicator          smallint NULL,
   ResourceEnterpriseCost2Indicator          smallint NULL,
   ResourceEnterpriseCost3Indicator          smallint NULL,
   ResourceEnterpriseCost4Indicator          smallint NULL,
   ResourceEnterpriseCost5Indicator          smallint NULL,
   ResourceEnterpriseCost6Indicator          smallint NULL,
   ResourceEnterpriseCost7Indicator          smallint NULL,
   ResourceEnterpriseCost8Indicator          smallint NULL,
   ResourceEnterpriseCost9Indicator          smallint NULL,
   ResourceEnterpriseCost10Indicator         smallint NULL,
   ResourceEnterpriseDate1                   datetime NULL,
   ResourceEnterpriseDate2                   datetime NULL,
   ResourceEnterpriseDate3                   datetime NULL,
   ResourceEnterpriseDate4                   datetime NULL,
   ResourceEnterpriseDate5                   datetime NULL,
   ResourceEnterpriseDate6                   datetime NULL,
   ResourceEnterpriseDate7                   datetime NULL,
   ResourceEnterpriseDate8                   datetime NULL,
   ResourceEnterpriseDate9                   datetime NULL,
   ResourceEnterpriseDate10                  datetime NULL,
   ResourceEnterpriseDate11                  datetime NULL,
   ResourceEnterpriseDate12                  datetime NULL,
   ResourceEnterpriseDate13                  datetime NULL,
   ResourceEnterpriseDate14                  datetime NULL,
   ResourceEnterpriseDate15                  datetime NULL,
   ResourceEnterpriseDate16                  datetime NULL,
   ResourceEnterpriseDate17                  datetime NULL,
   ResourceEnterpriseDate18                  datetime NULL,
   ResourceEnterpriseDate19                  datetime NULL,
   ResourceEnterpriseDate20                  datetime NULL,
   ResourceEnterpriseDate21                  datetime NULL,
   ResourceEnterpriseDate22                  datetime NULL,
   ResourceEnterpriseDate23                  datetime NULL,
   ResourceEnterpriseDate24                  datetime NULL,
   ResourceEnterpriseDate25                  datetime NULL,
   ResourceEnterpriseDate26                  datetime NULL,
   ResourceEnterpriseDate27                  datetime NULL,
   ResourceEnterpriseDate28                  datetime NULL,
   ResourceEnterpriseDate29                  datetime NULL,
   ResourceEnterpriseDate30                  datetime NULL,
   ResourceEnterpriseDate1Indicator          smallint NULL,
   ResourceEnterpriseDate2Indicator          smallint NULL,
   ResourceEnterpriseDate3Indicator          smallint NULL,
   ResourceEnterpriseDate4Indicator          smallint NULL,
   ResourceEnterpriseDate5Indicator          smallint NULL,
   ResourceEnterpriseDate6Indicator          smallint NULL,
   ResourceEnterpriseDate7Indicator          smallint NULL,
   ResourceEnterpriseDate8Indicator          smallint NULL,
   ResourceEnterpriseDate9Indicator          smallint NULL,
   ResourceEnterpriseDate10Indicator         smallint NULL,
   ResourceEnterpriseDate11Indicator         smallint NULL,
   ResourceEnterpriseDate12Indicator         smallint NULL,
   ResourceEnterpriseDate13Indicator         smallint NULL,
   ResourceEnterpriseDate14Indicator         smallint NULL,
   ResourceEnterpriseDate15Indicator         smallint NULL,
   ResourceEnterpriseDate16Indicator         smallint NULL,
   ResourceEnterpriseDate17Indicator         smallint NULL,
   ResourceEnterpriseDate18Indicator         smallint NULL,
   ResourceEnterpriseDate19Indicator         smallint NULL,
   ResourceEnterpriseDate20Indicator         smallint NULL,
   ResourceEnterpriseDate21Indicator         smallint NULL,
   ResourceEnterpriseDate22Indicator         smallint NULL,
   ResourceEnterpriseDate23Indicator         smallint NULL,
   ResourceEnterpriseDate24Indicator         smallint NULL,
   ResourceEnterpriseDate25Indicator         smallint NULL,
   ResourceEnterpriseDate26Indicator         smallint NULL,
   ResourceEnterpriseDate27Indicator         smallint NULL,
   ResourceEnterpriseDate28Indicator         smallint NULL,
   ResourceEnterpriseDate29Indicator         smallint NULL,
   ResourceEnterpriseDate30Indicator         smallint NULL,
   ResourceEnterpriseDuration1               int NULL,
   ResourceEnterpriseDuration2               int NULL,
   ResourceEnterpriseDuration3               int NULL,
   ResourceEnterpriseDuration4               int NULL,
   ResourceEnterpriseDuration5               int NULL,
   ResourceEnterpriseDuration6               int NULL,
   ResourceEnterpriseDuration7               int NULL,
   ResourceEnterpriseDuration8               int NULL,
   ResourceEnterpriseDuration9               int NULL,
   ResourceEnterpriseDuration10              int NULL,
   ResourceEnterpriseDuration1Indicator      smallint NULL,
   ResourceEnterpriseDuration2Indicator      smallint NULL,
   ResourceEnterpriseDuration3Indicator      smallint NULL,
   ResourceEnterpriseDuration4Indicator      smallint NULL,
   ResourceEnterpriseDuration5Indicator      smallint NULL,
   ResourceEnterpriseDuration6Indicator      smallint NULL,
   ResourceEnterpriseDuration7Indicator      smallint NULL,
   ResourceEnterpriseDuration8Indicator      smallint NULL,
   ResourceEnterpriseDuration9Indicator      smallint NULL,
   ResourceEnterpriseDuration10Indicator     smallint NULL,
   ResourceEnterpriseFlag1                   tinyint NULL,
   ResourceEnterpriseFlag2                   tinyint NULL,
   ResourceEnterpriseFlag3                   tinyint NULL,
   ResourceEnterpriseFlag4                   tinyint NULL,
   ResourceEnterpriseFlag5                   tinyint NULL,
   ResourceEnterpriseFlag6                   tinyint NULL,
   ResourceEnterpriseFlag7                   tinyint NULL,
   ResourceEnterpriseFlag8                   tinyint NULL,
   ResourceEnterpriseFlag9                   tinyint NULL,
   ResourceEnterpriseFlag10                  tinyint NULL,
   ResourceEnterpriseFlag11                  tinyint NULL,
   ResourceEnterpriseFlag12                  tinyint NULL,
   ResourceEnterpriseFlag13                  tinyint NULL,
   ResourceEnterpriseFlag14                  tinyint NULL,
   ResourceEnterpriseFlag15                  tinyint NULL,
   ResourceEnterpriseFlag16                  tinyint NULL,
   ResourceEnterpriseFlag17                  tinyint NULL,
   ResourceEnterpriseFlag18                  tinyint NULL,
   ResourceEnterpriseFlag19                  tinyint NULL,
   ResourceEnterpriseFlag20                  tinyint NULL,
   ResourceEnterpriseFlag1Indicator          smallint NULL,
   ResourceEnterpriseFlag2Indicator          smallint NULL,
   ResourceEnterpriseFlag3Indicator          smallint NULL,
   ResourceEnterpriseFlag4Indicator          smallint NULL,
   ResourceEnterpriseFlag5Indicator          smallint NULL,
   ResourceEnterpriseFlag6Indicator          smallint NULL,
   ResourceEnterpriseFlag7Indicator          smallint NULL,
   ResourceEnterpriseFlag8Indicator          smallint NULL,
   ResourceEnterpriseFlag9Indicator          smallint NULL,
   ResourceEnterpriseFlag10Indicator         smallint NULL,
   ResourceEnterpriseFlag11Indicator         smallint NULL,
   ResourceEnterpriseFlag12Indicator         smallint NULL,
   ResourceEnterpriseFlag13Indicator         smallint NULL,
   ResourceEnterpriseFlag14Indicator         smallint NULL,
   ResourceEnterpriseFlag15Indicator         smallint NULL,
   ResourceEnterpriseFlag16Indicator         smallint NULL,
   ResourceEnterpriseFlag17Indicator         smallint NULL,
   ResourceEnterpriseFlag18Indicator         smallint NULL,
   ResourceEnterpriseFlag19Indicator         smallint NULL,
   ResourceEnterpriseFlag20Indicator         smallint NULL,
   ResourceEnterpriseGeneric                 smallint NULL,
   ResourceEnterpriseNumber1                 decimal (25,6) NULL,
   ResourceEnterpriseNumber2                 decimal (25,6) NULL,
   ResourceEnterpriseNumber3                 decimal (25,6) NULL,
   ResourceEnterpriseNumber4                 decimal (25,6) NULL,
   ResourceEnterpriseNumber5                 decimal (25,6) NULL,
   ResourceEnterpriseNumber6                 decimal (25,6) NULL,
   ResourceEnterpriseNumber7                 decimal (25,6) NULL,
   ResourceEnterpriseNumber8                 decimal (25,6) NULL,
   ResourceEnterpriseNumber9                 decimal (25,6) NULL,
   ResourceEnterpriseNumber10                decimal (25,6) NULL,
   ResourceEnterpriseNumber11                decimal (25,6) NULL,
   ResourceEnterpriseNumber12                decimal (25,6) NULL,
   ResourceEnterpriseNumber13                decimal (25,6) NULL,
   ResourceEnterpriseNumber14                decimal (25,6) NULL,
   ResourceEnterpriseNumber15                decimal (25,6) NULL,
   ResourceEnterpriseNumber16                decimal (25,6) NULL,
   ResourceEnterpriseNumber17                decimal (25,6) NULL,
   ResourceEnterpriseNumber18                decimal (25,6) NULL,
   ResourceEnterpriseNumber19                decimal (25,6) NULL,
   ResourceEnterpriseNumber20                decimal (25,6) NULL,
   ResourceEnterpriseNumber21                decimal (25,6) NULL,
   ResourceEnterpriseNumber22                decimal (25,6) NULL,
   ResourceEnterpriseNumber23                decimal (25,6) NULL,
   ResourceEnterpriseNumber24                decimal (25,6) NULL,
   ResourceEnterpriseNumber25                decimal (25,6) NULL,
   ResourceEnterpriseNumber26                decimal (25,6) NULL,
   ResourceEnterpriseNumber27                decimal (25,6) NULL,
   ResourceEnterpriseNumber28                decimal (25,6) NULL,
   ResourceEnterpriseNumber29                decimal (25,6) NULL,
   ResourceEnterpriseNumber30                decimal (25,6) NULL,
   ResourceEnterpriseNumber31                decimal (25,6) NULL,
   ResourceEnterpriseNumber32                decimal (25,6) NULL,
   ResourceEnterpriseNumber33                decimal (25,6) NULL,
   ResourceEnterpriseNumber34                decimal (25,6) NULL,
   ResourceEnterpriseNumber35                decimal (25,6) NULL,
   ResourceEnterpriseNumber36                decimal (25,6) NULL,
   ResourceEnterpriseNumber37                decimal (25,6) NULL,
   ResourceEnterpriseNumber38                decimal (25,6) NULL,
   ResourceEnterpriseNumber39                decimal (25,6) NULL,
   ResourceEnterpriseNumber40                decimal (25,6) NULL,
   ResourceEnterpriseNumber1Indicator        smallint NULL,
   ResourceEnterpriseNumber2Indicator        smallint NULL,
   ResourceEnterpriseNumber3Indicator        smallint NULL,
   ResourceEnterpriseNumber4Indicator        smallint NULL,
   ResourceEnterpriseNumber5Indicator        smallint NULL,
   ResourceEnterpriseNumber6Indicator        smallint NULL,
   ResourceEnterpriseNumber7Indicator        smallint NULL,
   ResourceEnterpriseNumber8Indicator        smallint NULL,
   ResourceEnterpriseNumber9Indicator        smallint NULL,
   ResourceEnterpriseNumber10Indicator       smallint NULL,
   ResourceEnterpriseNumber11Indicator       smallint NULL,
   ResourceEnterpriseNumber12Indicator       smallint NULL,
   ResourceEnterpriseNumber13Indicator       smallint NULL,
   ResourceEnterpriseNumber14Indicator       smallint NULL,
   ResourceEnterpriseNumber15Indicator       smallint NULL,
   ResourceEnterpriseNumber16Indicator       smallint NULL,
   ResourceEnterpriseNumber17Indicator       smallint NULL,
   ResourceEnterpriseNumber18Indicator       smallint NULL,
   ResourceEnterpriseNumber19Indicator       smallint NULL,
   ResourceEnterpriseNumber20Indicator       smallint NULL,
   ResourceEnterpriseNumber21Indicator       smallint NULL,
   ResourceEnterpriseNumber22Indicator       smallint NULL,
   ResourceEnterpriseNumber23Indicator       smallint NULL,
   ResourceEnterpriseNumber24Indicator       smallint NULL,
   ResourceEnterpriseNumber25Indicator       smallint NULL,
   ResourceEnterpriseNumber26Indicator       smallint NULL,
   ResourceEnterpriseNumber27Indicator       smallint NULL,
   ResourceEnterpriseNumber28Indicator       smallint NULL,
   ResourceEnterpriseNumber29Indicator       smallint NULL,
   ResourceEnterpriseNumber30Indicator       smallint NULL,
   ResourceEnterpriseNumber31Indicator       smallint NULL,
   ResourceEnterpriseNumber32Indicator       smallint NULL,
   ResourceEnterpriseNumber33Indicator       smallint NULL,
   ResourceEnterpriseNumber34Indicator       smallint NULL,
   ResourceEnterpriseNumber35Indicator       smallint NULL,
   ResourceEnterpriseNumber36Indicator       smallint NULL,
   ResourceEnterpriseNumber37Indicator       smallint NULL,
   ResourceEnterpriseNumber38Indicator       smallint NULL,
   ResourceEnterpriseNumber39Indicator       smallint NULL,
   ResourceEnterpriseNumber40Indicator       smallint NULL,
   ResourceEnterpriseOutlineCode1ID          integer NULL,
   ResourceEnterpriseOutlineCode2ID          integer NULL,
   ResourceEnterpriseOutlineCode3ID          integer NULL,
   ResourceEnterpriseOutlineCode4ID          integer NULL,
   ResourceEnterpriseOutlineCode5ID          integer NULL,
   ResourceEnterpriseOutlineCode6ID          integer NULL,
   ResourceEnterpriseOutlineCode7ID          integer NULL,
   ResourceEnterpriseOutlineCode8ID          integer NULL,
   ResourceEnterpriseOutlineCode9ID          integer NULL,
   ResourceEnterpriseOutlineCode10ID         integer NULL,
   ResourceEnterpriseOutlineCode11ID         integer NULL,
   ResourceEnterpriseOutlineCode12ID         integer NULL,
   ResourceEnterpriseOutlineCode13ID         integer NULL,
   ResourceEnterpriseOutlineCode14ID         integer NULL,
   ResourceEnterpriseOutlineCode15ID         integer NULL,
   ResourceEnterpriseOutlineCode16ID         integer NULL,
   ResourceEnterpriseOutlineCode17ID         integer NULL,
   ResourceEnterpriseOutlineCode18ID         integer NULL,
   ResourceEnterpriseOutlineCode19ID         integer NULL,
   ResourceEnterpriseOutlineCode20ID         integer NULL,
   ResourceEnterpriseOutlineCode21ID         integer NULL,
   ResourceEnterpriseOutlineCode22ID         integer NULL,
   ResourceEnterpriseOutlineCode23ID         integer NULL,
   ResourceEnterpriseOutlineCode24ID         integer NULL,
   ResourceEnterpriseOutlineCode25ID         integer NULL,
   ResourceEnterpriseOutlineCode26ID         integer NULL,
   ResourceEnterpriseOutlineCode27ID         integer NULL,
   ResourceEnterpriseOutlineCode28ID         integer NULL,
   ResourceEnterpriseOutlineCode29ID         integer NULL,
   ResourceEnterpriseOutlineCode30ID         integer NULL,
   ResourceEnterpriseText1                   ntext NULL,
   ResourceEnterpriseText2                   ntext NULL,
   ResourceEnterpriseText3                   ntext NULL,
   ResourceEnterpriseText4                   ntext NULL,
   ResourceEnterpriseText5                   ntext NULL,
   ResourceEnterpriseText6                   ntext NULL,
   ResourceEnterpriseText7                   ntext NULL,
   ResourceEnterpriseText8                   ntext NULL,
   ResourceEnterpriseText9                   ntext NULL,
   ResourceEnterpriseText10                  ntext NULL,
   ResourceEnterpriseText11                  ntext NULL,
   ResourceEnterpriseText12                  ntext NULL,
   ResourceEnterpriseText13                  ntext NULL,
   ResourceEnterpriseText14                  ntext NULL,
   ResourceEnterpriseText15                  ntext NULL,
   ResourceEnterpriseText16                  ntext NULL,
   ResourceEnterpriseText17                  ntext NULL,
   ResourceEnterpriseText18                  ntext NULL,
   ResourceEnterpriseText19                  ntext NULL,
   ResourceEnterpriseText20                  ntext NULL,
   ResourceEnterpriseText21                  ntext NULL,
   ResourceEnterpriseText22                  ntext NULL,
   ResourceEnterpriseText23                  ntext NULL,
   ResourceEnterpriseText24                  ntext NULL,
   ResourceEnterpriseText25                  ntext NULL,
   ResourceEnterpriseText26                  ntext NULL,
   ResourceEnterpriseText27                  ntext NULL,
   ResourceEnterpriseText28                  ntext NULL,
   ResourceEnterpriseText29                  ntext NULL,
   ResourceEnterpriseText30                  ntext NULL,
   ResourceEnterpriseText31                  ntext NULL,
   ResourceEnterpriseText32                  ntext NULL,
   ResourceEnterpriseText33                  ntext NULL,
   ResourceEnterpriseText34                  ntext NULL,
   ResourceEnterpriseText35                  ntext NULL,
   ResourceEnterpriseText36                  ntext NULL,
   ResourceEnterpriseText37                  ntext NULL,
   ResourceEnterpriseText38                  ntext NULL,
   ResourceEnterpriseText39                  ntext NULL,
   ResourceEnterpriseText40                  ntext NULL,
   ResourceEnterpriseText1Indicator          smallint NULL,
   ResourceEnterpriseText2Indicator          smallint NULL,
   ResourceEnterpriseText3Indicator          smallint NULL,
   ResourceEnterpriseText4Indicator          smallint NULL,
   ResourceEnterpriseText5Indicator          smallint NULL,
   ResourceEnterpriseText6Indicator          smallint NULL,
   ResourceEnterpriseText7Indicator          smallint NULL,
   ResourceEnterpriseText8Indicator          smallint NULL,
   ResourceEnterpriseText9Indicator          smallint NULL,
   ResourceEnterpriseText10Indicator         smallint NULL,
   ResourceEnterpriseText11Indicator         smallint NULL,
   ResourceEnterpriseText12Indicator         smallint NULL,
   ResourceEnterpriseText13Indicator         smallint NULL,
   ResourceEnterpriseText14Indicator         smallint NULL,
   ResourceEnterpriseText15Indicator         smallint NULL,
   ResourceEnterpriseText16Indicator         smallint NULL,
   ResourceEnterpriseText17Indicator         smallint NULL,
   ResourceEnterpriseText18Indicator         smallint NULL,
   ResourceEnterpriseText19Indicator         smallint NULL,
   ResourceEnterpriseText20Indicator         smallint NULL,
   ResourceEnterpriseText21Indicator         smallint NULL,
   ResourceEnterpriseText22Indicator         smallint NULL,
   ResourceEnterpriseText23Indicator         smallint NULL,
   ResourceEnterpriseText24Indicator         smallint NULL,
   ResourceEnterpriseText25Indicator         smallint NULL,
   ResourceEnterpriseText26Indicator         smallint NULL,
   ResourceEnterpriseText27Indicator         smallint NULL,
   ResourceEnterpriseText28Indicator         smallint NULL,
   ResourceEnterpriseText29Indicator         smallint NULL,
   ResourceEnterpriseText30Indicator         smallint NULL,
   ResourceEnterpriseText31Indicator         smallint NULL,
   ResourceEnterpriseText32Indicator         smallint NULL,
   ResourceEnterpriseText33Indicator         smallint NULL,
   ResourceEnterpriseText34Indicator         smallint NULL,
   ResourceEnterpriseText35Indicator         smallint NULL,
   ResourceEnterpriseText36Indicator         smallint NULL,
   ResourceEnterpriseText37Indicator         smallint NULL,
   ResourceEnterpriseText38Indicator         smallint NULL,
   ResourceEnterpriseText39Indicator         smallint NULL,
   ResourceEnterpriseText40Indicator         smallint NULL,
   CONSTRAINT PK_MSP_VIEW_PROJ_RES_ENT_WPROJ_ID_ENT_ResourceUniqueID PRIMARY KEY CLUSTERED(WPROJ_ID, ENT_ResourceUniqueID) 
)
GO

CREATE INDEX I_VIEW_RES_ENT_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_RES_ENT(ENT_ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_STD
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   AssignmentUniqueID                        int NOT NULL, 
   ResourceEnterpriseUniqueID                int NOT NULL,  
   ResourceUniqueID                          int NULL,	    
   TaskUniqueID                              int NULL,	    
   AssignmentPercentWorkComplete             smallint NULL,
   AssignmentActualCost                      decimal (25,6) NULL,
   AssignmentActualFinish                    datetime NULL,
   AssignmentActualOvertimeCost              decimal (25,6) NULL,
   AssignmentActualOvertimeWork              decimal (25,6) NULL,
   AssignmentActualStart                     datetime NULL,
   AssignmentActualWork                      decimal (25,6) NULL,
   AssignmentACWP                            decimal (25,6) NULL,
   AssignmentBaselineCost                    decimal (25,6) NULL,
   AssignmentBaselineFinish                  datetime NULL,
   AssignmentBaselineStart                   datetime NULL,
   AssignmentBaselineWork                    decimal (25,6) NULL,
   AssignmentBCWP                            decimal (25,6) NULL,
   AssignmentBCWS                            decimal (25,6) NULL,
   AssignmentConfirmed                       tinyint NULL,
   AssignmentCost                            decimal (25,6) NULL,
   CostRateTable                             smallint NULL,
   AssignmentCostVariance                    decimal (25,6) NULL,
   AssignmentCV                              decimal (25,6) NULL,
   AssignmentDelay                           int NULL,
   AssignmentFinish                          datetime NULL,
   AssignmentFinishVariance                  int NULL,
   AssignmentFixedMaterial                   tinyint NULL,
   AssignmentHasFixedRateUnits               tinyint NULL,
   AssignmentHyperlink                       ntext NULL,
   AssignmentHyperlinkAddress                ntext NULL,
   AssignmentHyperlinkHref                   ntext NULL,
   AssignmentHyperlinkScreenTip              ntext NULL,
   AssignmentHyperlinkSubAddress             ntext NULL,
   AssignmentLevelingDelay                   int NULL,
   AssignmentLinkedFields                    tinyint NULL,
   AssignmentMilestone                       tinyint NULL,
   AssignmentNotes                           ntext NULL,
   AssignmentOtherType                       smallint NULL,
   AssignmentOverallocated                   tinyint NULL,
   AssignmentOvertimeCost                    decimal (25,6) NULL,
   AssignmentOvertimeWork                    decimal (25,6) NULL,
   AssignmentPeakUnits                       decimal (25,6) NULL,
   AssignmentRegularWork                     decimal (25,6) NULL,
   AssignmentRemainingCost                   decimal (25,6) NULL,
   AssignmentRemainingOvertimeCost           decimal (25,6) NULL,
   AssignmentRemainingOvertimeWork           decimal (25,6) NULL,
   AssignmentRemainingWork                   decimal (25,6) NULL,
   AssignmentRemainingWorkContour            image NULL,
   AssignmentResourceID                      int NULL,
   AssignmentResourceName                    nvarchar (255) NULL,
   AssignmentResourceRequestType             smallint NULL,
   AssignmentResourceType                    smallint NULL,
   AssignmentResponsePending                 tinyint NULL,
   AssignmentStart                           datetime NULL,
   AssignmentStartVariance                   int NULL,
   AssignmentSummary                         tinyint NULL,
   AssignmentSV                              decimal (25,6) NULL,
   AssignmentTaskID                          int NULL,
   AssignmentTaskName                        nvarchar (255) NULL,
   AssignmentTaskSummaryName                 nvarchar (255) NULL,
   AssignmentTeamStatusPending               tinyint NULL,
   AssignmentUnits                           decimal (25,6) NULL,
   AssignmentUpdateNeeded                    tinyint NULL,
   AssignmentVAC                             decimal (25,6) NULL,
   AssignmentWork                            decimal (25,6) NULL,
   AssignmentWorkContour                     smallint NULL,
   AssignmentWorkVariance                    decimal (25,6) NULL,
)
GO

CREATE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_STD 
ON dbo.MSP_VIEW_PROJ_ASSN_STD(WPROJ_ID, AssignmentUniqueID) 
WITH FILLFACTOR = 40 
GO

CREATE INDEX I_VIEW_ASSN_STD_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_STD(ProjectUniqueID)
GO

CREATE INDEX I_VIEW_ASSN_STD_REUID
ON dbo.MSP_VIEW_PROJ_ASSN_STD(ResourceEnterpriseUniqueID)

CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_CF
(
   WPROJ_ID                                  int NOT NULL,
   CF_ProjectUniqueID                        int NOT NULL,
   CF_AssignmentUniqueID                     int NOT NULL, 
   CF_ResourceEnterpriseUniqueID             int NOT NULL,
   AssignmentCost1                           decimal (25,6) NULL,
   AssignmentCost2                           decimal (25,6) NULL,
   AssignmentCost3                           decimal (25,6) NULL,
   AssignmentCost4                           decimal (25,6) NULL,
   AssignmentCost5                           decimal (25,6) NULL,
   AssignmentCost6                           decimal (25,6) NULL,
   AssignmentCost7                           decimal (25,6) NULL,
   AssignmentCost8                           decimal (25,6) NULL,
   AssignmentCost9                           decimal (25,6) NULL,
   AssignmentCost10                          decimal (25,6) NULL,
   AssignmentDate1                           datetime NULL,
   AssignmentDate2                           datetime NULL,
   AssignmentDate3                           datetime NULL,
   AssignmentDate4                           datetime NULL,
   AssignmentDate5                           datetime NULL,
   AssignmentDate6                           datetime NULL,
   AssignmentDate7                           datetime NULL,
   AssignmentDate8                           datetime NULL,
   AssignmentDate9                           datetime NULL,
   AssignmentDate10                          datetime NULL,
   AssignmentDuration1                       int NULL,
   AssignmentDuration2                       int NULL,
   AssignmentDuration3                       int NULL,
   AssignmentDuration4                       int NULL,
   AssignmentDuration5                       int NULL,
   AssignmentDuration6                       int NULL,
   AssignmentDuration7                       int NULL,
   AssignmentDuration8                       int NULL,
   AssignmentDuration9                       int NULL,
   AssignmentDuration10                      int NULL,
   AssignmentFinish1                         datetime NULL,
   AssignmentFinish2                         datetime NULL,
   AssignmentFinish3                         datetime NULL,
   AssignmentFinish4                         datetime NULL,
   AssignmentFinish5                         datetime NULL,
   AssignmentFinish6                         datetime NULL,
   AssignmentFinish7                         datetime NULL,
   AssignmentFinish8                         datetime NULL,
   AssignmentFinish9                         datetime NULL,
   AssignmentFinish10                        datetime NULL,
   AssignmentFlag1                           tinyint NULL,
   AssignmentFlag2                           tinyint NULL,
   AssignmentFlag3                           tinyint NULL,
   AssignmentFlag4                           tinyint NULL,
   AssignmentFlag5                           tinyint NULL,
   AssignmentFlag6                           tinyint NULL,
   AssignmentFlag7                           tinyint NULL,
   AssignmentFlag8                           tinyint NULL,
   AssignmentFlag9                           tinyint NULL,
   AssignmentFlag10                          tinyint NULL,
   AssignmentFlag11                          tinyint NULL,
   AssignmentFlag12                          tinyint NULL,
   AssignmentFlag13                          tinyint NULL,
   AssignmentFlag14                          tinyint NULL,
   AssignmentFlag15                          tinyint NULL,
   AssignmentFlag16                          tinyint NULL,
   AssignmentFlag17                          tinyint NULL,
   AssignmentFlag18                          tinyint NULL,
   AssignmentFlag19                          tinyint NULL,
   AssignmentFlag20                          tinyint NULL,
   AssignmentNumber1                         decimal (25,6) NULL,
   AssignmentNumber2                         decimal (25,6) NULL,
   AssignmentNumber3                         decimal (25,6) NULL,
   AssignmentNumber4                         decimal (25,6) NULL,
   AssignmentNumber5                         decimal (25,6) NULL,
   AssignmentNumber6                         decimal (25,6) NULL,
   AssignmentNumber7                         decimal (25,6) NULL,
   AssignmentNumber8                         decimal (25,6) NULL,
   AssignmentNumber9                         decimal (25,6) NULL,
   AssignmentNumber10                        decimal (25,6) NULL,
   AssignmentNumber11                        decimal (25,6) NULL,
   AssignmentNumber12                        decimal (25,6) NULL,
   AssignmentNumber13                        decimal (25,6) NULL,
   AssignmentNumber14                        decimal (25,6) NULL,
   AssignmentNumber15                        decimal (25,6) NULL,
   AssignmentNumber16                        decimal (25,6) NULL,
   AssignmentNumber17                        decimal (25,6) NULL,
   AssignmentNumber18                        decimal (25,6) NULL,
   AssignmentNumber19                        decimal (25,6) NULL,
   AssignmentNumber20                        decimal (25,6) NULL,
   AssignmentStart1                          datetime NULL,
   AssignmentStart2                          datetime NULL,
   AssignmentStart3                          datetime NULL,
   AssignmentStart4                          datetime NULL,
   AssignmentStart5                          datetime NULL,
   AssignmentStart6                          datetime NULL,
   AssignmentStart7                          datetime NULL,
   AssignmentStart8                          datetime NULL,
   AssignmentStart9                          datetime NULL,
   AssignmentStart10                         datetime NULL,
   AssignmentText1                           ntext NULL,
   AssignmentText2                           ntext NULL,
   AssignmentText3                           ntext NULL,
   AssignmentText4                           ntext NULL,
   AssignmentText5                           ntext NULL,
   AssignmentText6                           ntext NULL,
   AssignmentText7                           ntext NULL,
   AssignmentText8                           ntext NULL,
   AssignmentText9                           ntext NULL,
   AssignmentText10                          ntext NULL,
   AssignmentText11                          ntext NULL,
   AssignmentText12                          ntext NULL,
   AssignmentText13                          ntext NULL,
   AssignmentText14                          ntext NULL,
   AssignmentText15                          ntext NULL,
   AssignmentText16                          ntext NULL,
   AssignmentText17                          ntext NULL,
   AssignmentText18                          ntext NULL,
   AssignmentText19                          ntext NULL,
   AssignmentText20                          ntext NULL,
   AssignmentText21                          ntext NULL,
   AssignmentText22                          ntext NULL,
   AssignmentText23                          ntext NULL,
   AssignmentText24                          ntext NULL,
   AssignmentText25                          ntext NULL,
   AssignmentText26                          ntext NULL,
   AssignmentText27                          ntext NULL,
   AssignmentText28                          ntext NULL,
   AssignmentText29                          ntext NULL,
   AssignmentText30                          ntext NULL,
)
GO
-- PRIMARY KEY??
CREATE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_CF 
ON dbo.MSP_VIEW_PROJ_ASSN_CF(WPROJ_ID, CF_AssignmentUniqueID) 
WITH FILLFACTOR = 40
GO

CREATE INDEX I_VIEW_ASSN_CF_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_CF(CF_ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_ENT
(
   WPROJ_ID                                  int NOT NULL,
   ENT_ProjectUniqueID                       int NOT NULL,
   ENT_AssignmentUniqueID                    int NOT NULL, 
   ENT_ResourceEnterpriseUniqueID            int NOT NULL,
   AssignmentEnterpriseCost1                 decimal (25,6) NULL,
   AssignmentEnterpriseCost2                 decimal (25,6) NULL,
   AssignmentEnterpriseCost3                 decimal (25,6) NULL,
   AssignmentEnterpriseCost4                 decimal (25,6) NULL,
   AssignmentEnterpriseCost5                 decimal (25,6) NULL,
   AssignmentEnterpriseCost6                 decimal (25,6) NULL,
   AssignmentEnterpriseCost7                 decimal (25,6) NULL,
   AssignmentEnterpriseCost8                 decimal (25,6) NULL,
   AssignmentEnterpriseCost9                 decimal (25,6) NULL,
   AssignmentEnterpriseCost10                decimal (25,6) NULL,
   AssignmentEnterpriseDate1                 datetime NULL,
   AssignmentEnterpriseDate2                 datetime NULL,
   AssignmentEnterpriseDate3                 datetime NULL,
   AssignmentEnterpriseDate4                 datetime NULL,
   AssignmentEnterpriseDate5                 datetime NULL,
   AssignmentEnterpriseDate6                 datetime NULL,
   AssignmentEnterpriseDate7                 datetime NULL,
   AssignmentEnterpriseDate8                 datetime NULL,
   AssignmentEnterpriseDate9                 datetime NULL,
   AssignmentEnterpriseDate10                datetime NULL,
   AssignmentEnterpriseDate11                datetime NULL,
   AssignmentEnterpriseDate12                datetime NULL,
   AssignmentEnterpriseDate13                datetime NULL,
   AssignmentEnterpriseDate14                datetime NULL,
   AssignmentEnterpriseDate15                datetime NULL,
   AssignmentEnterpriseDate16                datetime NULL,
   AssignmentEnterpriseDate17                datetime NULL,
   AssignmentEnterpriseDate18                datetime NULL,
   AssignmentEnterpriseDate19                datetime NULL,
   AssignmentEnterpriseDate20                datetime NULL,
   AssignmentEnterpriseDate21                datetime NULL,
   AssignmentEnterpriseDate22                datetime NULL,
   AssignmentEnterpriseDate23                datetime NULL,
   AssignmentEnterpriseDate24                datetime NULL,
   AssignmentEnterpriseDate25                datetime NULL,
   AssignmentEnterpriseDate26                datetime NULL,
   AssignmentEnterpriseDate27                datetime NULL,
   AssignmentEnterpriseDate28                datetime NULL,
   AssignmentEnterpriseDate29                datetime NULL,
   AssignmentEnterpriseDate30                datetime NULL,
   AssignmentEnterpriseDuration1             int NULL,
   AssignmentEnterpriseDuration2             int NULL,
   AssignmentEnterpriseDuration3             int NULL,
   AssignmentEnterpriseDuration4             int NULL,
   AssignmentEnterpriseDuration5             int NULL,
   AssignmentEnterpriseDuration6             int NULL,
   AssignmentEnterpriseDuration7             int NULL,
   AssignmentEnterpriseDuration8             int NULL,
   AssignmentEnterpriseDuration9             int NULL,
   AssignmentEnterpriseDuration10            int NULL,
   AssignmentEnterpriseFlag1                 tinyint NULL,
   AssignmentEnterpriseFlag2                 tinyint NULL,
   AssignmentEnterpriseFlag3                 tinyint NULL,
   AssignmentEnterpriseFlag4                 tinyint NULL,
   AssignmentEnterpriseFlag5                 tinyint NULL,
   AssignmentEnterpriseFlag6                 tinyint NULL,
   AssignmentEnterpriseFlag7                 tinyint NULL,
   AssignmentEnterpriseFlag8                 tinyint NULL,
   AssignmentEnterpriseFlag9                 tinyint NULL,
   AssignmentEnterpriseFlag10                tinyint NULL,
   AssignmentEnterpriseFlag11                tinyint NULL,
   AssignmentEnterpriseFlag12                tinyint NULL,
   AssignmentEnterpriseFlag13                tinyint NULL,
   AssignmentEnterpriseFlag14                tinyint NULL,
   AssignmentEnterpriseFlag15                tinyint NULL,
   AssignmentEnterpriseFlag16                tinyint NULL,
   AssignmentEnterpriseFlag17                tinyint NULL,
   AssignmentEnterpriseFlag18                tinyint NULL,
   AssignmentEnterpriseFlag19                tinyint NULL,
   AssignmentEnterpriseFlag20                tinyint NULL,
   AssignmentEnterpriseNumber1               decimal (25,6) NULL,
   AssignmentEnterpriseNumber2               decimal (25,6) NULL,
   AssignmentEnterpriseNumber3               decimal (25,6) NULL,
   AssignmentEnterpriseNumber4               decimal (25,6) NULL,
   AssignmentEnterpriseNumber5               decimal (25,6) NULL,
   AssignmentEnterpriseNumber6               decimal (25,6) NULL,
   AssignmentEnterpriseNumber7               decimal (25,6) NULL,
   AssignmentEnterpriseNumber8               decimal (25,6) NULL,
   AssignmentEnterpriseNumber9               decimal (25,6) NULL,
   AssignmentEnterpriseNumber10              decimal (25,6) NULL,
   AssignmentEnterpriseNumber11              decimal (25,6) NULL,
   AssignmentEnterpriseNumber12              decimal (25,6) NULL,
   AssignmentEnterpriseNumber13              decimal (25,6) NULL,
   AssignmentEnterpriseNumber14              decimal (25,6) NULL,
   AssignmentEnterpriseNumber15              decimal (25,6) NULL,
   AssignmentEnterpriseNumber16              decimal (25,6) NULL,
   AssignmentEnterpriseNumber17              decimal (25,6) NULL,
   AssignmentEnterpriseNumber18              decimal (25,6) NULL,
   AssignmentEnterpriseNumber19              decimal (25,6) NULL,
   AssignmentEnterpriseNumber20              decimal (25,6) NULL,
   AssignmentEnterpriseNumber21              decimal (25,6) NULL,
   AssignmentEnterpriseNumber22              decimal (25,6) NULL,
   AssignmentEnterpriseNumber23              decimal (25,6) NULL,
   AssignmentEnterpriseNumber24              decimal (25,6) NULL,
   AssignmentEnterpriseNumber25              decimal (25,6) NULL,
   AssignmentEnterpriseNumber26              decimal (25,6) NULL,
   AssignmentEnterpriseNumber27              decimal (25,6) NULL,
   AssignmentEnterpriseNumber28              decimal (25,6) NULL,
   AssignmentEnterpriseNumber29              decimal (25,6) NULL,
   AssignmentEnterpriseNumber30              decimal (25,6) NULL,
   AssignmentEnterpriseNumber31              decimal (25,6) NULL,
   AssignmentEnterpriseNumber32              decimal (25,6) NULL,
   AssignmentEnterpriseNumber33              decimal (25,6) NULL,
   AssignmentEnterpriseNumber34              decimal (25,6) NULL,
   AssignmentEnterpriseNumber35              decimal (25,6) NULL,
   AssignmentEnterpriseNumber36              decimal (25,6) NULL,
   AssignmentEnterpriseNumber37              decimal (25,6) NULL,
   AssignmentEnterpriseNumber38              decimal (25,6) NULL,
   AssignmentEnterpriseNumber39              decimal (25,6) NULL,
   AssignmentEnterpriseNumber40              decimal (25,6) NULL,
   AssignmentEnterpriseOutlineCode1ID        integer NULL,
   AssignmentEnterpriseOutlineCode2ID        integer NULL,
   AssignmentEnterpriseOutlineCode3ID        integer NULL,
   AssignmentEnterpriseOutlineCode4ID        integer NULL,
   AssignmentEnterpriseOutlineCode5ID        integer NULL,
   AssignmentEnterpriseOutlineCode6ID        integer NULL,
   AssignmentEnterpriseOutlineCode7ID        integer NULL,
   AssignmentEnterpriseOutlineCode8ID        integer NULL,
   AssignmentEnterpriseOutlineCode9ID        integer NULL,
   AssignmentEnterpriseOutlineCode10ID       integer NULL,
   AssignmentEnterpriseOutlineCode11ID       integer NULL,
   AssignmentEnterpriseOutlineCode12ID       integer NULL,
   AssignmentEnterpriseOutlineCode13ID       integer NULL,
   AssignmentEnterpriseOutlineCode14ID       integer NULL,
   AssignmentEnterpriseOutlineCode15ID       integer NULL,
   AssignmentEnterpriseOutlineCode16ID       integer NULL,
   AssignmentEnterpriseOutlineCode17ID       integer NULL,
   AssignmentEnterpriseOutlineCode18ID       integer NULL,
   AssignmentEnterpriseOutlineCode19ID       integer NULL,
   AssignmentEnterpriseOutlineCode20ID       integer NULL,
   AssignmentEnterpriseOutlineCode21ID       integer NULL,
   AssignmentEnterpriseOutlineCode22ID       integer NULL,
   AssignmentEnterpriseOutlineCode23ID       integer NULL,
   AssignmentEnterpriseOutlineCode24ID       integer NULL,
   AssignmentEnterpriseOutlineCode25ID       integer NULL,
   AssignmentEnterpriseOutlineCode26ID       integer NULL,
   AssignmentEnterpriseOutlineCode27ID       integer NULL,
   AssignmentEnterpriseOutlineCode28ID       integer NULL,
   AssignmentEnterpriseOutlineCode29ID       integer NULL,
   AssignmentEnterpriseOutlineCode30ID       integer NULL,
   AssignmentEnterpriseText1                 ntext NULL,
   AssignmentEnterpriseText2                 ntext NULL,
   AssignmentEnterpriseText3                 ntext NULL,
   AssignmentEnterpriseText4                 ntext NULL,
   AssignmentEnterpriseText5                 ntext NULL,
   AssignmentEnterpriseText6                 ntext NULL,
   AssignmentEnterpriseText7                 ntext NULL,
   AssignmentEnterpriseText8                 ntext NULL,
   AssignmentEnterpriseText9                 ntext NULL,
   AssignmentEnterpriseText10                ntext NULL,
   AssignmentEnterpriseText11                ntext NULL,
   AssignmentEnterpriseText12                ntext NULL,
   AssignmentEnterpriseText13                ntext NULL,
   AssignmentEnterpriseText14                ntext NULL,
   AssignmentEnterpriseText15                ntext NULL,
   AssignmentEnterpriseText16                ntext NULL,
   AssignmentEnterpriseText17                ntext NULL,
   AssignmentEnterpriseText18                ntext NULL,
   AssignmentEnterpriseText19                ntext NULL,
   AssignmentEnterpriseText20                ntext NULL,
   AssignmentEnterpriseText21                ntext NULL,
   AssignmentEnterpriseText22                ntext NULL,
   AssignmentEnterpriseText23                ntext NULL,
   AssignmentEnterpriseText24                ntext NULL,
   AssignmentEnterpriseText25                ntext NULL,
   AssignmentEnterpriseText26                ntext NULL,
   AssignmentEnterpriseText27                ntext NULL,
   AssignmentEnterpriseText28                ntext NULL,
   AssignmentEnterpriseText29                ntext NULL,
   AssignmentEnterpriseText30                ntext NULL,
   AssignmentEnterpriseText31                ntext NULL,
   AssignmentEnterpriseText32                ntext NULL,
   AssignmentEnterpriseText33                ntext NULL,
   AssignmentEnterpriseText34                ntext NULL,
   AssignmentEnterpriseText35                ntext NULL,
   AssignmentEnterpriseText36                ntext NULL,
   AssignmentEnterpriseText37                ntext NULL,
   AssignmentEnterpriseText38                ntext NULL,
   AssignmentEnterpriseText39                ntext NULL,
   AssignmentEnterpriseText40                ntext NULL
)
GO

CREATE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_ENT 
ON dbo.MSP_VIEW_PROJ_ASSN_ENT(WPROJ_ID, ENT_AssignmentUniqueID) 
WITH FILLFACTOR = 40
GO

CREATE INDEX I_VIEW_ASSN_ENT_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_ENT(ENT_ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_TASKSPLITS
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   TaskUniqueID                              int NULL,
   SplitStart                                datetime NULL,
   SplitFinish                               datetime NULL
)
GO

CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_TASKSPLITS 
ON dbo.MSP_VIEW_PROJ_TASKSPLITS(WPROJ_ID, TaskUniqueID, SplitStart) 
GO

CREATE INDEX I_VIEW_TASKSPLITS_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASKSPLITS(ProjectUniqueID)
GO



CREATE TABLE dbo.MSP_VIEW_PROJ_PRED
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   TaskUniqueID                              int NULL, 
   PredecessorTaskUniqueID                   int NULL, 
   PredecessorLag                            int NULL,
   PredecessorPath                           nvarchar (260) NULL,
   PredecessorType                           smallint NULL,
   PredecessorLagType                        smallint NULL
)
GO

CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_PRED 
ON dbo.MSP_VIEW_PROJ_PRED(WPROJ_ID, TaskUniqueID, PredecessorTaskUniqueID) 
GO

CREATE INDEX I_VIEW_PRED_PROJECTUNIQUEID
ON dbo.MSP_VIEW_PROJ_PRED(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_SUCC
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   TaskUniqueID                              int NULL, 
   SuccessorTaskUniqueID                     int NULL, 
   SuccessorLag                              int NULL,
   SuccessorPath                             nvarchar (260) NULL,
   SuccessorType                             smallint NULL
)
GO

CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_SUCC 
ON dbo.MSP_VIEW_PROJ_SUCC(WPROJ_ID, TaskUniqueID, SuccessorTaskUniqueID) 
GO

CREATE INDEX I_VIEW_SUCC_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_SUCC(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_TASK_TP_BY_DAY
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   TaskUniqueID                              int NULL,  
   TaskTimeStart                             datetime NULL,
   TaskTimeFinish                            datetime NULL,
   TaskTimeFixedCost                         decimal (25,6) NULL,
   TaskTimeActualFixedCost                   decimal (25,6) NULL
)
GO


CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_TASK_TP_BY_DAY 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_DAY(WPROJ_ID, TaskUniqueID, TaskTimeStart) 
GO

CREATE INDEX I_VIEW_TASK_TP_BY_DAY_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_TASK_TP_BY_DAY(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_ASSN_TP_BY_DAY
(
   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,
   AssignmentTimeBaselineCost                decimal (25,6) NULL,
   AssignmentTimeBaselineWork                decimal (25,6) NULL,
   AssignmentTimeCost                        decimal (25,6) NULL,
   AssignmentTimeCumulativeCost              decimal (25,6) NULL,
   AssignmentTimeCumulativeWork              decimal (25,6) NULL,
   AssignmentTimeOvertimeWork                decimal (25,6) NULL,
   AssignmentTimePeakUnits                   decimal (25,6) NULL,
   AssignmentTimeRegularWork                 decimal (25,6) NULL,
   AssignmentTimeWork                        decimal (25,6) NULL
)
GO

CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_ASSN_TP_BY_DAY 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_DAY(WPROJ_ID, AssignmentUniqueID, AssignmentTimeStart) 
GO

CREATE INDEX I_VIEW_ASSN_TP_BY_DAY_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_ASSN_TP_BY_DAY(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_CAL
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   CalendarUniqueID                          int NOT NULL,
   ResourceUniqueID                          int NULL,   	
   ResourceEnterpriseUniqueID                int NULL,
   CalendarName                              nvarchar (255) NULL,
   CalendarIsBaseCalendar                    tinyint NULL,
   CalendarBaseCalendarUniqueID              int NULL,
   CONSTRAINT PK_MSP_VIEW_PROJ_CAL_WPROJ_ID_CalendarUniqueID PRIMARY KEY CLUSTERED (WPROJ_ID, CalendarUniqueID) 
)
GO


CREATE INDEX I_VIEW_CAL_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_CAL(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_CAL_DATA
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   CalendarUniqueID                          int NOT NULL,
   CalendarWeekday                           int NULL, 
   CalendarWorking                           int NULL,
   CalendarFromDate                          datetime NULL,
   CalendarToDate                            datetime NULL,
   CalendarFromTime1                         datetime NULL,
   CalendarToTime1                           datetime NULL,
   CalendarFromTime2                         datetime NULL,
   CalendarToTime2                           datetime NULL,
   CalendarFromTime3                         datetime NULL,
   CalendarToTime3                           datetime NULL,
   CalendarFromTime4                         datetime NULL,
   CalendarToTime4                           datetime NULL,
   CalendarFromTime5                         datetime NULL,
   CalendarToTime5                           datetime NULL
)
GO

CREATE UNIQUE INDEX PK_MSP_VIEW_PROJ_CAL_DATA 
ON dbo.MSP_VIEW_PROJ_CAL_DATA(WPROJ_ID, CalendarUniqueID, CalendarWeekday) 
GO

CREATE INDEX I_VIEW_CAL_DATA_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_CAL_DATA(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_PROJ_CAL_EXCEPTIONS
(
   WPROJ_ID                                  int NOT NULL,
   ProjectUniqueID                           int NOT NULL,
   CalendarUniqueID                          int NOT NULL,
   CalendarExceptionFromDate                 datetime NULL, 
   CalendarExceptionToDate                   datetime NULL,
   CalendarExceptionWorking                  int NULL,
   CalendarExceptionFromTime1                datetime NULL,
   CalendarExceptionFromTime2                datetime NULL,
   CalendarExceptionFromTime3                datetime NULL,
   CalendarExceptionToTime1                  datetime NULL,
   CalendarExceptionToTime2                  datetime NULL,
   CalendarExceptionToTime3                  datetime NULL
)
GO

CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_PROJ_CAL_EXCEPTIONS 
ON dbo.MSP_VIEW_PROJ_CAL_EXCEPTIONS(WPROJ_ID, CalendarUniqueID, CalendarExceptionFromDate) 
GO

CREATE INDEX I_VIEW_CAL_EXCEPTIONS_PROJECTUNIQUEID 
ON dbo.MSP_VIEW_PROJ_CAL_EXCEPTIONS(ProjectUniqueID)
GO

CREATE TABLE dbo.MSP_VIEW_RES_STD
(
   ResourceUniqueID                          int NOT NULL 
	CONSTRAINT PK_MSP_VIEW_RES_STD_ResourceUniqueID  PRIMARY KEY CLUSTERED,
   ResourceBaseline1Cost                     decimal (25,6) NULL,
   ResourceBaseline2Cost                     decimal (25,6) NULL,
   ResourceBaseline3Cost                     decimal (25,6) NULL,
   ResourceBaseline4Cost                     decimal (25,6) NULL,
   ResourceBaseline5Cost                     decimal (25,6) NULL,
   ResourceBaseline6Cost                     decimal (25,6) NULL,
   ResourceBaseline7Cost                     decimal (25,6) NULL,
   ResourceBaseline8Cost                     decimal (25,6) NULL,
   ResourceBaseline9Cost                     decimal (25,6) NULL,
   ResourceBaseline10Cost                    decimal (25,6) NULL,
   ResourceBaselineFinish                    datetime NULL,
   ResourceBaseline1Finish                   datetime NULL,
   ResourceBaseline2Finish                   datetime NULL,
   ResourceBaseline3Finish                   datetime NULL,
   ResourceBaseline4Finish                   datetime NULL,
   ResourceBaseline5Finish                   datetime NULL,
   ResourceBaseline6Finish                   datetime NULL,
   ResourceBaseline7Finish                   datetime NULL,
   ResourceBaseline8Finish                   datetime NULL,
   ResourceBaseline9Finish                   datetime NULL,
   ResourceBaseline10Finish                  datetime NULL,
   ResourceBaselineStart                     datetime NULL,
   ResourceBaseline1Start                    datetime NULL,
   ResourceBaseline2Start                    datetime NULL,
   ResourceBaseline3Start                    datetime NULL,
   ResourceBaseline4Start                    datetime NULL,
   ResourceBaseline5Start                    datetime NULL,
   ResourceBaseline6Start                    datetime NULL,
   ResourceBaseline7Start                    datetime NULL,
   ResourceBaseline8Start                    datetime NULL,
   ResourceBaseline9Start                    datetime NULL,
   ResourceBaseline10Start                   datetime NULL,
   ResourceBaseline1Work                     decimal (25,6) NULL,
   ResourceBaseline2Work                     decimal (25,6) NULL,
   ResourceBaseline3Work                     decimal (25,6) NULL,
   ResourceBaseline4Work                     decimal (25,6) NULL,
   ResourceBaseline5Work                     decimal (25,6) NULL,
   ResourceBaseline6Work                     decimal (25,6) NULL,
   ResourceBaseline7Work                     decimal (25,6) NULL,
   ResourceBaseline8Work                     decimal (25,6) NULL,
   ResourceBaseline9Work                     decimal (25,6) NULL,
   ResourceBaseline10Work                    decimal (25,6) NULL,
   ResourcePercentWorkComplete               smallint NULL,
   ResourceAccrueAt                          smallint NULL,
   ResourceActualCost                        decimal (25,6) NULL,
   ResourceActualOvertimeCost                decimal (25,6) NULL,
   ResourceActualOvertimeWork                decimal (25,6) NULL,
   ResourceActualWork                        decimal (25,6) NULL,
   ResourceACWP                              decimal (25,6) NULL,
   ResourceAvailableFrom                     datetime NULL,
   ResourceAvailableTo                       datetime NULL,
   ResourceBaseCalendar                      ntext NULL,
   ResourceBaselineCost                      decimal (25,6) NULL,
   ResourceBaselineWork                      decimal (25,6) NULL,
   ResourceBCWP                              decimal (25,6) NULL,
   ResourceBCWS                              decimal (25,6) NULL,
   ResourceCanLevel                          tinyint NULL,
   ResourceCode                              ntext NULL,
   ResourceConfirmed                         tinyint NULL,
   ResourceCost                              decimal (25,6) NULL,
   ResourceCostPerUse                        decimal (25,6) NULL,
   ResourceCostVariance                      decimal (25,6) NULL,
   ResourceCV                                decimal (25,6) NULL,
   ResourceEmailAddress                      ntext NULL,
   ResourceFinish                            datetime NULL,
   ResourceGroup                             ntext NULL,
   ResourceHyperlink                         ntext NULL,
   ResourceHyperlinkAddress                  ntext NULL,
   ResourceHyperlinkHref                     ntext NULL,
   ResourceHyperlinkScreenTip                ntext NULL,
   ResourceHyperlinkSubAddress               ntext NULL,
   ResourceID                                int NULL,
   ResourceInitials                          ntext NULL,
   ResourceIsNull                            tinyint NULL,
   ResourceLastPublished                     datetime NULL,
   ResourceLinkedFields                      tinyint NULL,
   ResourceMaterialLabel                     ntext NULL,
   ResourceMaxUnits                          decimal (25,6) NULL,
   ResourceName                              nvarchar (255) NULL,
   ResourceNotes                             ntext NULL,
   ResourceNTAccount                         ntext NULL,
   ResourceObjects                           int NULL,
   ResourceOverallocated                     tinyint NULL,
   ResourceOvertimeCost                      decimal (25,6) NULL,
   ResourceOvertimeRate                      decimal (25,6) NULL,
   ResourceOvertimeWork                      decimal (25,6) NULL,
   ResourcePeakUnits                         decimal (25,6) NULL,
   ResourcePhonetics                         ntext NULL,
   ResourceRegularWork                       decimal (25,6) NULL,
   ResourceRemainingCost                     decimal (25,6) NULL,
   ResourceRemainingOvertimeCost             decimal (25,6) NULL,
   ResourceRemainingOvertimeWork             decimal (25,6) NULL,
   ResourceRemainingWork                     decimal (25,6) NULL,
   ResourceResponsePending                   tinyint NULL,
   ResourceStandardRate                      decimal (25,6) NULL,
   ResourceStart                             datetime NULL,
   ResourceSV                                decimal (25,6) NULL,
   ResourceTeamStatusPending                 tinyint NULL,
   ResourceType                              smallint NULL,
   ResourceUpdateNeeded                      tinyint NULL,
   ResourceVAC                               decimal (25,6) NULL,
   ResourceWork                              decimal (25,6) NULL,
   ResourceWorkgroup                         smallint NULL,
   ResourceWorkVariance                      decimal (25,6) NULL
)
GO

CREATE TABLE dbo.MSP_VIEW_RES_CF
(
   CF_ResourceUniqueID                       int NOT NULL CONSTRAINT PK_MSP_VIEW_RES_CF_CF_ResourceUniqueID  PRIMARY KEY CLUSTERED,
   ResourceCost1                             decimal (25,6) NULL,
   ResourceCost2                             decimal (25,6) NULL,
   ResourceCost3                             decimal (25,6) NULL,
   ResourceCost4                             decimal (25,6) NULL,
   ResourceCost5                             decimal (25,6) NULL,
   ResourceCost6                             decimal (25,6) NULL,
   ResourceCost7                             decimal (25,6) NULL,
   ResourceCost8                             decimal (25,6) NULL,
   ResourceCost9                             decimal (25,6) NULL,
   ResourceCost10                            decimal (25,6) NULL,
   ResourceCost1Indicator                    smallint NULL,
   ResourceCost2Indicator                    smallint NULL,
   ResourceCost3Indicator                    smallint NULL,
   ResourceCost4Indicator                    smallint NULL,
   ResourceCost5Indicator                    smallint NULL,
   ResourceCost6Indicator                    smallint NULL,
   ResourceCost7Indicator                    smallint NULL,
   ResourceCost8Indicator                    smallint NULL,
   ResourceCost9Indicator                    smallint NULL,
   ResourceCost10Indicator                   smallint NULL,
   ResourceDate1                             datetime NULL,
   ResourceDate2                             datetime NULL,
   ResourceDate3                             datetime NULL,
   ResourceDate4                             datetime NULL,
   ResourceDate5                             datetime NULL,
   ResourceDate6                             datetime NULL,
   ResourceDate7                             datetime NULL,
   ResourceDate8                             datetime NULL,
   ResourceDate9                             datetime NULL,
   ResourceDate10                            datetime NULL,
   ResourceDate1Indicator                    smallint NULL,
   ResourceDate2Indicator                    smallint NULL,
   ResourceDate3Indicator                    smallint NULL,
   ResourceDate4Indicator                    smallint NULL,
   ResourceDate5Indicator                    smallint NULL,
   ResourceDate6Indicator                    smallint NULL,
   ResourceDate7Indicator                    smallint NULL,
   ResourceDate8Indicator                    smallint NULL,
   ResourceDate9Indicator                    smallint NULL,
   ResourceDate10Indicator                   smallint NULL,
   ResourceDuration1                         int NULL,
   ResourceDuration2                         int NULL,
   ResourceDuration3                         int NULL,
   ResourceDuration4                         int NULL,
   ResourceDuration5                         int NULL,
   ResourceDuration6                         int NULL,
   ResourceDuration7                         int NULL,
   ResourceDuration8                         int NULL,
   ResourceDuration9                         int NULL,
   ResourceDuration10                        int NULL,
   ResourceDuration1Indicator                smallint NULL,
   ResourceDuration2Indicator                smallint NULL,
   ResourceDuration3Indicator                smallint NULL,
   ResourceDuration4Indicator                smallint NULL,
   ResourceDuration5Indicator                smallint NULL,
   ResourceDuration6Indicator                smallint NULL,
   ResourceDuration7Indicator                smallint NULL,
   ResourceDuration8Indicator                smallint NULL,
   ResourceDuration9Indicator                smallint NULL,
   ResourceDuration10Indicator               smallint NULL,
   ResourceFinish1                           datetime NULL,
   ResourceFinish2                           datetime NULL,
   ResourceFinish3                           datetime NULL,
   ResourceFinish4                           datetime NULL,
   ResourceFinish5                           datetime NULL,
   ResourceFinish6                           datetime NULL,
   ResourceFinish7                           datetime NULL,
   ResourceFinish8                           datetime NULL,
   ResourceFinish9                           datetime NULL,
   ResourceFinish10                          datetime NULL,
   ResourceFinish1Indicator                  smallint NULL,
   ResourceFinish2Indicator                  smallint NULL,
   ResourceFinish3Indicator                  smallint NULL,
   ResourceFinish4Indicator                  smallint NULL,
   ResourceFinish5Indicator                  smallint NULL,
   ResourceFinish6Indicator                  smallint NULL,
   ResourceFinish7Indicator                  smallint NULL,
   ResourceFinish8Indicator                  smallint NULL,
   ResourceFinish9Indicator                  smallint NULL,
   ResourceFinish10Indicator                 smallint NULL,
   ResourceFlag1                             tinyint NULL,
   ResourceFlag2                             tinyint NULL,
   ResourceFlag3                             tinyint NULL,
   ResourceFlag4                             tinyint NULL,
   ResourceFlag5                             tinyint NULL,
   ResourceFlag6                             tinyint NULL,
   ResourceFlag7                             tinyint NULL,
   ResourceFlag8                             tinyint NULL,
   ResourceFlag9                             tinyint NULL,
   ResourceFlag10                            tinyint NULL,
   ResourceFlag11                            tinyint NULL,
   ResourceFlag12                            tinyint NULL,
   ResourceFlag13                            tinyint NULL,
   ResourceFlag14                            tinyint NULL,
   ResourceFlag15                            tinyint NULL,
   ResourceFlag16                            tinyint NULL,
   ResourceFlag17                            tinyint NULL,
   ResourceFlag18                            tinyint NULL,
   ResourceFlag19                            tinyint NULL,
   ResourceFlag20                            tinyint NULL,
   ResourceFlag1Indicator                    smallint NULL,
   ResourceFlag2Indicator                    smallint NULL,
   ResourceFlag3Indicator                    smallint NULL,
   ResourceFlag4Indicator                    smallint NULL,
   ResourceFlag5Indicator                    smallint NULL,
   ResourceFlag6Indicator                    smallint NULL,
   ResourceFlag7Indicator                    smallint NULL,
   ResourceFlag8Indicator                    smallint NULL,
   ResourceFlag9Indicator                    smallint NULL,
   ResourceFlag10Indicator                   smallint NULL,
   ResourceFlag11Indicator                   smallint NULL,
   ResourceFlag12Indicator                   smallint NULL,
   ResourceFlag13Indicator                   smallint NULL,
   ResourceFlag14Indicator                   smallint NULL,
   ResourceFlag15Indicator                   smallint NULL,
   ResourceFlag16Indicator                   smallint NULL,
   ResourceFlag17Indicator                   smallint NULL,
   ResourceFlag18Indicator                   smallint NULL,
   ResourceFlag19Indicator                   smallint NULL,
   ResourceFlag20Indicator                   smallint NULL,
   ResourceNumber1                           decimal (25,6) NULL,
   ResourceNumber2                           decimal (25,6) NULL,
   ResourceNumber3                           decimal (25,6) NULL,
   ResourceNumber4                           decimal (25,6) NULL,
   ResourceNumber5                           decimal (25,6) NULL,
   ResourceNumber6                           decimal (25,6) NULL,
   ResourceNumber7                           decimal (25,6) NULL,
   ResourceNumber8                           decimal (25,6) NULL,
   ResourceNumber9                           decimal (25,6) NULL,
   ResourceNumber10                          decimal (25,6) NULL,
   ResourceNumber11                          decimal (25,6) NULL,
   ResourceNumber12                          decimal (25,6) NULL,
   ResourceNumber13                          decimal (25,6) NULL,
   ResourceNumber14                          decimal (25,6) NULL,
   ResourceNumber15                          decimal (25,6) NULL,
   ResourceNumber16                          decimal (25,6) NULL,
   ResourceNumber17                          decimal (25,6) NULL,
   ResourceNumber18                          decimal (25,6) NULL,
   ResourceNumber19                          decimal (25,6) NULL,
   ResourceNumber20                          decimal (25,6) NULL,
   ResourceNumber1Indicator                  smallint NULL,
   ResourceNumber2Indicator                  smallint NULL,
   ResourceNumber3Indicator                  smallint NULL,
   ResourceNumber4Indicator                  smallint NULL,
   ResourceNumber5Indicator                  smallint NULL,
   ResourceNumber6Indicator                  smallint NULL,
   ResourceNumber7Indicator                  smallint NULL,
   ResourceNumber8Indicator                  smallint NULL,
   ResourceNumber9Indicator                  smallint NULL,
   ResourceNumber10Indicator                 smallint NULL,
   ResourceNumber11Indicator                 smallint NULL,
   ResourceNumber12Indicator                 smallint NULL,
   ResourceNumber13Indicator                 smallint NULL,
   ResourceNumber14Indicator                 smallint NULL,
   ResourceNumber15Indicator                 smallint NULL,
   ResourceNumber16Indicator                 smallint NULL,
   ResourceNumber17Indicator                 smallint NULL,
   ResourceNumber18Indicator                 smallint NULL,
   ResourceNumber19Indicator                 smallint NULL,
   ResourceNumber20Indicator                 smallint NULL,
   ResourceOutlineCode1                      ntext NULL,
   ResourceOutlineCode2                      ntext NULL,
   ResourceOutlineCode3                      ntext NULL,
   ResourceOutlineCode4                      ntext NULL,
   ResourceOutlineCode5                      ntext NULL,
   ResourceOutlineCode6                      ntext NULL,
   ResourceOutlineCode7                      ntext NULL,
   ResourceOutlineCode8                      ntext NULL,
   ResourceOutlineCode9                      ntext NULL,
   ResourceOutlineCode10                     ntext NULL,
   ResourceStart1                            datetime NULL,
   ResourceStart2                            datetime NULL,
   ResourceStart3                            datetime NULL,
   ResourceStart4                            datetime NULL,
   ResourceStart5                            datetime NULL,
   ResourceStart6                            datetime NULL,
   ResourceStart7                            datetime NULL,
   ResourceStart8                            datetime NULL,
   ResourceStart9                            datetime NULL,
   ResourceStart10                           datetime NULL,
   ResourceStart1Indicator                   smallint NULL,
   ResourceStart2Indicator                   smallint NULL,
   ResourceStart3Indicator                   smallint NULL,
   ResourceStart4Indicator                   smallint NULL,
   ResourceStart5Indicator                   smallint NULL,
   ResourceStart6Indicator                   smallint NULL,
   ResourceStart7Indicator                   smallint NULL,
   ResourceStart8Indicator                   smallint NULL,
   ResourceStart9Indicator                   smallint NULL,
   ResourceStart10Indicator                  smallint NULL,
   ResourceText1                             ntext NULL,
   ResourceText2                             ntext NULL,
   ResourceText3                             ntext NULL,
   ResourceText4                             ntext NULL,
   ResourceText5                             ntext NULL,
   ResourceText6                             ntext NULL,
   ResourceText7                             ntext NULL,
   ResourceText8                             ntext NULL,
   ResourceText9                             ntext NULL,
   ResourceText10                            ntext NULL,
   ResourceText11                            ntext NULL,
   ResourceText12                            ntext NULL,
   ResourceText13                            ntext NULL,
   ResourceText14                            ntext NULL,
   ResourceText15                            ntext NULL,
   ResourceText16                            ntext NULL,
   ResourceText17                            ntext NULL,
   ResourceText18                            ntext NULL,
   ResourceText19                            ntext NULL,
   ResourceText20                            ntext NULL,
   ResourceText21                            ntext NULL,
   ResourceText22                            ntext NULL,
   ResourceText23                            ntext NULL,
   ResourceText24                            ntext NULL,
   ResourceText25                            ntext NULL,
   ResourceText26                            ntext NULL,
   ResourceText27                            ntext NULL,
   ResourceText28                            ntext NULL,
   ResourceText29                            ntext NULL,
   ResourceText30                            ntext NULL,
   ResourceText1Indicator                    smallint NULL,
   ResourceText2Indicator                    smallint NULL,
   ResourceText3Indicator                    smallint NULL,
   ResourceText4Indicator                    smallint NULL,
   ResourceText5Indicator                    smallint NULL,
   ResourceText6Indicator                    smallint NULL,
   ResourceText7Indicator                    smallint NULL,
   ResourceText8Indicator                    smallint NULL,
   ResourceText9Indicator                    smallint NULL,
   ResourceText10Indicator                   smallint NULL,
   ResourceText11Indicator                   smallint NULL,
   ResourceText12Indicator                   smallint NULL,
   ResourceText13Indicator                   smallint NULL,
   ResourceText14Indicator                   smallint NULL,
   ResourceText15Indicator                   smallint NULL,
   ResourceText16Indicator                   smallint NULL,
   ResourceText17Indicator                   smallint NULL,
   ResourceText18Indicator                   smallint NULL,
   ResourceText19Indicator                   smallint NULL,
   ResourceText20Indicator                   smallint NULL,
   ResourceText21Indicator                   smallint NULL,
   ResourceText22Indicator                   smallint NULL,
   ResourceText23Indicator                   smallint NULL,
   ResourceText24Indicator                   smallint NULL,
   ResourceText25Indicator                   smallint NULL,
   ResourceText26Indicator                   smallint NULL,
   ResourceText27Indicator                   smallint NULL,
   ResourceText28Indicator                   smallint NULL,
   ResourceText29Indicator                   smallint NULL,
   ResourceText30Indicator                   smallint NULL
)
GO

CREATE TABLE dbo.MSP_VIEW_RES_ENT
(
   ENT_ResourceUniqueID                      int NOT NULL
   	CONSTRAINT PK_MSP_VIEW_RES_ENT_ENT_ResourceUniqueID PRIMARY KEY CLUSTERED, 
   ResourceEnterpriseCost1                   decimal (25,6) NULL,
   ResourceEnterpriseCost2                   decimal (25,6) NULL,
   ResourceEnterpriseCost3                   decimal (25,6) NULL,
   ResourceEnterpriseCost4                   decimal (25,6) NULL,
   ResourceEnterpriseCost5                   decimal (25,6) NULL,
   ResourceEnterpriseCost6                   decimal (25,6) NULL,
   ResourceEnterpriseCost7                   decimal (25,6) NULL,
   ResourceEnterpriseCost8                   decimal (25,6) NULL,
   ResourceEnterpriseCost9                   decimal (25,6) NULL,
   ResourceEnterpriseCost10                  decimal (25,6) NULL,
   ResourceEnterpriseCost1Indicator          smallint NULL,
   ResourceEnterpriseCost2Indicator          smallint NULL,
   ResourceEnterpriseCost3Indicator          smallint NULL,
   ResourceEnterpriseCost4Indicator          smallint NULL,
   ResourceEnterpriseCost5Indicator          smallint NULL,
   ResourceEnterpriseCost6Indicator          smallint NULL,
   ResourceEnterpriseCost7Indicator          smallint NULL,
   ResourceEnterpriseCost8Indicator          smallint NULL,
   ResourceEnterpriseCost9Indicator          smallint NULL,
   ResourceEnterpriseCost10Indicator         smallint NULL,
   ResourceEnterpriseDate1                   datetime NULL,
   ResourceEnterpriseDate2                   datetime NULL,
   ResourceEnterpriseDate3                   datetime NULL,
   ResourceEnterpriseDate4                   datetime NULL,
   ResourceEnterpriseDate5                   datetime NULL,
   ResourceEnterpriseDate6                   datetime NULL,
   ResourceEnterpriseDate7                   datetime NULL,
   ResourceEnterpriseDate8                   datetime NULL,
   ResourceEnterpriseDate9                   datetime NULL,
   ResourceEnterpriseDate10                  datetime NULL,
   ResourceEnterpriseDate11                  datetime NULL,
   ResourceEnterpriseDate12                  datetime NULL,
   ResourceEnterpriseDate13                  datetime NULL,
   ResourceEnterpriseDate14                  datetime NULL,
   ResourceEnterpriseDate15                  datetime NULL,
   ResourceEnterpriseDate16                  datetime NULL,
   ResourceEnterpriseDate17                  datetime NULL,
   ResourceEnterpriseDate18                  datetime NULL,
   ResourceEnterpriseDate19                  datetime NULL,
   ResourceEnterpriseDate20                  datetime NULL,
   ResourceEnterpriseDate21                  datetime NULL,
   ResourceEnterpriseDate22                  datetime NULL,
   ResourceEnterpriseDate23                  datetime NULL,
   ResourceEnterpriseDate24                  datetime NULL,
   ResourceEnterpriseDate25                  datetime NULL,
   ResourceEnterpriseDate26                  datetime NULL,
   ResourceEnterpriseDate27                  datetime NULL,
   ResourceEnterpriseDate28                  datetime NULL,
   ResourceEnterpriseDate29                  datetime NULL,
   ResourceEnterpriseDate30                  datetime NULL,
   ResourceEnterpriseDate1Indicator          smallint NULL,
   ResourceEnterpriseDate2Indicator          smallint NULL,
   ResourceEnterpriseDate3Indicator          smallint NULL,
   ResourceEnterpriseDate4Indicator          smallint NULL,
   ResourceEnterpriseDate5Indicator          smallint NULL,
   ResourceEnterpriseDate6Indicator          smallint NULL,
   ResourceEnterpriseDate7Indicator          smallint NULL,
   ResourceEnterpriseDate8Indicator          smallint NULL,
   ResourceEnterpriseDate9Indicator          smallint NULL,
   ResourceEnterpriseDate10Indicator         smallint NULL,
   ResourceEnterpriseDate11Indicator         smallint NULL,
   ResourceEnterpriseDate12Indicator         smallint NULL,
   ResourceEnterpriseDate13Indicator         smallint NULL,
   ResourceEnterpriseDate14Indicator         smallint NULL,
   ResourceEnterpriseDate15Indicator         smallint NULL,
   ResourceEnterpriseDate16Indicator         smallint NULL,
   ResourceEnterpriseDate17Indicator         smallint NULL,
   ResourceEnterpriseDate18Indicator         smallint NULL,
   ResourceEnterpriseDate19Indicator         smallint NULL,
   ResourceEnterpriseDate20Indicator         smallint NULL,
   ResourceEnterpriseDate21Indicator         smallint NULL,
   ResourceEnterpriseDate22Indicator         smallint NULL,
   ResourceEnterpriseDate23Indicator         smallint NULL,
   ResourceEnterpriseDate24Indicator         smallint NULL,
   ResourceEnterpriseDate25Indicator         smallint NULL,
   ResourceEnterpriseDate26Indicator         smallint NULL,
   ResourceEnterpriseDate27Indicator         smallint NULL,
   ResourceEnterpriseDate28Indicator         smallint NULL,
   ResourceEnterpriseDate29Indicator         smallint NULL,
   ResourceEnterpriseDate30Indicator         smallint NULL,
   ResourceEnterpriseDuration1               int NULL,
   ResourceEnterpriseDuration2               int NULL,
   ResourceEnterpriseDuration3               int NULL,
   ResourceEnterpriseDuration4               int NULL,
   ResourceEnterpriseDuration5               int NULL,
   ResourceEnterpriseDuration6               int NULL,
   ResourceEnterpriseDuration7               int NULL,
   ResourceEnterpriseDuration8               int NULL,
   ResourceEnterpriseDuration9               int NULL,
   ResourceEnterpriseDuration10              int NULL,
   ResourceEnterpriseDuration1Indicator      smallint NULL,
   ResourceEnterpriseDuration2Indicator      smallint NULL,
   ResourceEnterpriseDuration3Indicator      smallint NULL,
   ResourceEnterpriseDuration4Indicator      smallint NULL,
   ResourceEnterpriseDuration5Indicator      smallint NULL,
   ResourceEnterpriseDuration6Indicator      smallint NULL,
   ResourceEnterpriseDuration7Indicator      smallint NULL,
   ResourceEnterpriseDuration8Indicator      smallint NULL,
   ResourceEnterpriseDuration9Indicator      smallint NULL,
   ResourceEnterpriseDuration10Indicator     smallint NULL,
   ResourceEnterpriseFlag1                   tinyint NULL,
   ResourceEnterpriseFlag2                   tinyint NULL,
   ResourceEnterpriseFlag3                   tinyint NULL,
   ResourceEnterpriseFlag4                   tinyint NULL,
   ResourceEnterpriseFlag5                   tinyint NULL,
   ResourceEnterpriseFlag6                   tinyint NULL,
   ResourceEnterpriseFlag7                   tinyint NULL,
   ResourceEnterpriseFlag8                   tinyint NULL,
   ResourceEnterpriseFlag9                   tinyint NULL,
   ResourceEnterpriseFlag10                  tinyint NULL,
   ResourceEnterpriseFlag11                  tinyint NULL,
   ResourceEnterpriseFlag12                  tinyint NULL,
   ResourceEnterpriseFlag13                  tinyint NULL,
   ResourceEnterpriseFlag14                  tinyint NULL,
   ResourceEnterpriseFlag15                  tinyint NULL,
   ResourceEnterpriseFlag16                  tinyint NULL,
   ResourceEnterpriseFlag17                  tinyint NULL,
   ResourceEnterpriseFlag18                  tinyint NULL,
   ResourceEnterpriseFlag19                  tinyint NULL,
   ResourceEnterpriseFlag20                  tinyint NULL,
   ResourceEnterpriseFlag1Indicator          smallint NULL,
   ResourceEnterpriseFlag2Indicator          smallint NULL,
   ResourceEnterpriseFlag3Indicator          smallint NULL,
   ResourceEnterpriseFlag4Indicator          smallint NULL,
   ResourceEnterpriseFlag5Indicator          smallint NULL,
   ResourceEnterpriseFlag6Indicator          smallint NULL,
   ResourceEnterpriseFlag7Indicator          smallint NULL,
   ResourceEnterpriseFlag8Indicator          smallint NULL,
   ResourceEnterpriseFlag9Indicator          smallint NULL,
   ResourceEnterpriseFlag10Indicator         smallint NULL,
   ResourceEnterpriseFlag11Indicator         smallint NULL,
   ResourceEnterpriseFlag12Indicator         smallint NULL,
   ResourceEnterpriseFlag13Indicator         smallint NULL,
   ResourceEnterpriseFlag14Indicator         smallint NULL,
   ResourceEnterpriseFlag15Indicator         smallint NULL,
   ResourceEnterpriseFlag16Indicator         smallint NULL,
   ResourceEnterpriseFlag17Indicator         smallint NULL,
   ResourceEnterpriseFlag18Indicator         smallint NULL,
   ResourceEnterpriseFlag19Indicator         smallint NULL,
   ResourceEnterpriseFlag20Indicator         smallint NULL,
   ResourceEnterpriseGeneric                 smallint NULL,
   ResourceEnterpriseNumber1                 decimal (25,6) NULL,
   ResourceEnterpriseNumber2                 decimal (25,6) NULL,
   ResourceEnterpriseNumber3                 decimal (25,6) NULL,
   ResourceEnterpriseNumber4                 decimal (25,6) NULL,
   ResourceEnterpriseNumber5                 decimal (25,6) NULL,
   ResourceEnterpriseNumber6                 decimal (25,6) NULL,
   ResourceEnterpriseNumber7                 decimal (25,6) NULL,
   ResourceEnterpriseNumber8                 decimal (25,6) NULL,
   ResourceEnterpriseNumber9                 decimal (25,6) NULL,
   ResourceEnterpriseNumber10                decimal (25,6) NULL,
   ResourceEnterpriseNumber11                decimal (25,6) NULL,
   ResourceEnterpriseNumber12                decimal (25,6) NULL,
   ResourceEnterpriseNumber13                decimal (25,6) NULL,
   ResourceEnterpriseNumber14                decimal (25,6) NULL,
   ResourceEnterpriseNumber15                decimal (25,6) NULL,
   ResourceEnterpriseNumber16                decimal (25,6) NULL,
   ResourceEnterpriseNumber17                decimal (25,6) NULL,
   ResourceEnterpriseNumber18                decimal (25,6) NULL,
   ResourceEnterpriseNumber19                decimal (25,6) NULL,
   ResourceEnterpriseNumber20                decimal (25,6) NULL,
   ResourceEnterpriseNumber21                decimal (25,6) NULL,
   ResourceEnterpriseNumber22                decimal (25,6) NULL,
   ResourceEnterpriseNumber23                decimal (25,6) NULL,
   ResourceEnterpriseNumber24                decimal (25,6) NULL,
   ResourceEnterpriseNumber25                decimal (25,6) NULL,
   ResourceEnterpriseNumber26                decimal (25,6) NULL,
   ResourceEnterpriseNumber27                decimal (25,6) NULL,
   ResourceEnterpriseNumber28                decimal (25,6) NULL,
   ResourceEnterpriseNumber29                decimal (25,6) NULL,
   ResourceEnterpriseNumber30                decimal (25,6) NULL,
   ResourceEnterpriseNumber31                decimal (25,6) NULL,
   ResourceEnterpriseNumber32                decimal (25,6) NULL,
   ResourceEnterpriseNumber33                decimal (25,6) NULL,
   ResourceEnterpriseNumber34                decimal (25,6) NULL,
   ResourceEnterpriseNumber35                decimal (25,6) NULL,
   ResourceEnterpriseNumber36                decimal (25,6) NULL,
   ResourceEnterpriseNumber37                decimal (25,6) NULL,
   ResourceEnterpriseNumber38                decimal (25,6) NULL,
   ResourceEnterpriseNumber39                decimal (25,6) NULL,
   ResourceEnterpriseNumber40                decimal (25,6) NULL,
   ResourceEnterpriseNumber1Indicator        smallint NULL,
   ResourceEnterpriseNumber2Indicator        smallint NULL,
   ResourceEnterpriseNumber3Indicator        smallint NULL,
   ResourceEnterpriseNumber4Indicator        smallint NULL,
   ResourceEnterpriseNumber5Indicator        smallint NULL,
   ResourceEnterpriseNumber6Indicator        smallint NULL,
   ResourceEnterpriseNumber7Indicator        smallint NULL,
   ResourceEnterpriseNumber8Indicator        smallint NULL,
   ResourceEnterpriseNumber9Indicator        smallint NULL,
   ResourceEnterpriseNumber10Indicator       smallint NULL,
   ResourceEnterpriseNumber11Indicator       smallint NULL,
   ResourceEnterpriseNumber12Indicator       smallint NULL,
   ResourceEnterpriseNumber13Indicator       smallint NULL,
   ResourceEnterpriseNumber14Indicator       smallint NULL,
   ResourceEnterpriseNumber15Indicator       smallint NULL,
   ResourceEnterpriseNumber16Indicator       smallint NULL,
   ResourceEnterpriseNumber17Indicator       smallint NULL,
   ResourceEnterpriseNumber18Indicator       smallint NULL,
   ResourceEnterpriseNumber19Indicator       smallint NULL,
   ResourceEnterpriseNumber20Indicator       smallint NULL,
   ResourceEnterpriseNumber21Indicator       smallint NULL,
   ResourceEnterpriseNumber22Indicator       smallint NULL,
   ResourceEnterpriseNumber23Indicator       smallint NULL,
   ResourceEnterpriseNumber24Indicator       smallint NULL,
   ResourceEnterpriseNumber25Indicator       smallint NULL,
   ResourceEnterpriseNumber26Indicator       smallint NULL,
   ResourceEnterpriseNumber27Indicator       smallint NULL,
   ResourceEnterpriseNumber28Indicator       smallint NULL,
   ResourceEnterpriseNumber29Indicator       smallint NULL,
   ResourceEnterpriseNumber30Indicator       smallint NULL,
   ResourceEnterpriseNumber31Indicator       smallint NULL,
   ResourceEnterpriseNumber32Indicator       smallint NULL,
   ResourceEnterpriseNumber33Indicator       smallint NULL,
   ResourceEnterpriseNumber34Indicator       smallint NULL,
   ResourceEnterpriseNumber35Indicator       smallint NULL,
   ResourceEnterpriseNumber36Indicator       smallint NULL,
   ResourceEnterpriseNumber37Indicator       smallint NULL,
   ResourceEnterpriseNumber38Indicator       smallint NULL,
   ResourceEnterpriseNumber39Indicator       smallint NULL,
   ResourceEnterpriseNumber40Indicator       smallint NULL,
   ResourceEnterpriseOutlineCode1ID          integer NULL,
   ResourceEnterpriseOutlineCode2ID          integer NULL,
   ResourceEnterpriseOutlineCode3ID          integer NULL,
   ResourceEnterpriseOutlineCode4ID          integer NULL,
   ResourceEnterpriseOutlineCode5ID          integer NULL,
   ResourceEnterpriseOutlineCode6ID          integer NULL,
   ResourceEnterpriseOutlineCode7ID          integer NULL,
   ResourceEnterpriseOutlineCode8ID          integer NULL,
   ResourceEnterpriseOutlineCode9ID          integer NULL,
   ResourceEnterpriseOutlineCode10ID         integer NULL,
   ResourceEnterpriseOutlineCode11ID         integer NULL,
   ResourceEnterpriseOutlineCode12ID         integer NULL,
   ResourceEnterpriseOutlineCode13ID         integer NULL,
   ResourceEnterpriseOutlineCode14ID         integer NULL,
   ResourceEnterpriseOutlineCode15ID         integer NULL,
   ResourceEnterpriseOutlineCode16ID         integer NULL,
   ResourceEnterpriseOutlineCode17ID         integer NULL,
   ResourceEnterpriseOutlineCode18ID         integer NULL,
   ResourceEnterpriseOutlineCode19ID         integer NULL,
   ResourceEnterpriseOutlineCode20ID         integer NULL,
   ResourceEnterpriseOutlineCode21ID         integer NULL,
   ResourceEnterpriseOutlineCode22ID         integer NULL,
   ResourceEnterpriseOutlineCode23ID         integer NULL,
   ResourceEnterpriseOutlineCode24ID         integer NULL,
   ResourceEnterpriseOutlineCode25ID         integer NULL,
   ResourceEnterpriseOutlineCode26ID         integer NULL,
   ResourceEnterpriseOutlineCode27ID         integer NULL,
   ResourceEnterpriseOutlineCode28ID         integer NULL,
   ResourceEnterpriseOutlineCode29ID         integer NULL,
   ResourceEnterpriseOutlineCode30ID         integer NULL,
   ResourceEnterpriseText1                   ntext NULL,
   ResourceEnterpriseText2                   ntext NULL,
   ResourceEnterpriseText3                   ntext NULL,
   ResourceEnterpriseText4                   ntext NULL,
   ResourceEnterpriseText5                   ntext NULL,
   ResourceEnterpriseText6                   ntext NULL,
   ResourceEnterpriseText7                   ntext NULL,
   ResourceEnterpriseText8                   ntext NULL,
   ResourceEnterpriseText9                   ntext NULL,
   ResourceEnterpriseText10                  ntext NULL,
   ResourceEnterpriseText11                  ntext NULL,
   ResourceEnterpriseText12                  ntext NULL,
   ResourceEnterpriseText13                  ntext NULL,
   ResourceEnterpriseText14                  ntext NULL,
   ResourceEnterpriseText15                  ntext NULL,
   ResourceEnterpriseText16                  ntext NULL,
   ResourceEnterpriseText17                  ntext NULL,
   ResourceEnterpriseText18                  ntext NULL,
   ResourceEnterpriseText19                  ntext NULL,
   ResourceEnterpriseText20                  ntext NULL,
   ResourceEnterpriseText21                  ntext NULL,
   ResourceEnterpriseText22                  ntext NULL,
   ResourceEnterpriseText23                  ntext NULL,
   ResourceEnterpriseText24                  ntext NULL,
   ResourceEnterpriseText25                  ntext NULL,
   ResourceEnterpriseText26                  ntext NULL,
   ResourceEnterpriseText27                  ntext NULL,
   ResourceEnterpriseText28                  ntext NULL,
   ResourceEnterpriseText29                  ntext NULL,
   ResourceEnterpriseText30                  ntext NULL,
   ResourceEnterpriseText31                  ntext NULL,
   ResourceEnterpriseText32                  ntext NULL,
   ResourceEnterpriseText33                  ntext NULL,
   ResourceEnterpriseText34                  ntext NULL,
   ResourceEnterpriseText35                  ntext NULL,
   ResourceEnterpriseText36                  ntext NULL,
   ResourceEnterpriseText37                  ntext NULL,
   ResourceEnterpriseText38                  ntext NULL,
   ResourceEnterpriseText39                  ntext NULL,
   ResourceEnterpriseText40                  ntext NULL,
   ResourceEnterpriseText1Indicator          smallint NULL,
   ResourceEnterpriseText2Indicator          smallint NULL,
   ResourceEnterpriseText3Indicator          smallint NULL,
   ResourceEnterpriseText4Indicator          smallint NULL,
   ResourceEnterpriseText5Indicator          smallint NULL,
   ResourceEnterpriseText6Indicator          smallint NULL,
   ResourceEnterpriseText7Indicator          smallint NULL,
   ResourceEnterpriseText8Indicator          smallint NULL,
   ResourceEnterpriseText9Indicator          smallint NULL,
   ResourceEnterpriseText10Indicator         smallint NULL,
   ResourceEnterpriseText11Indicator         smallint NULL,
   ResourceEnterpriseText12Indicator         smallint NULL,
   ResourceEnterpriseText13Indicator         smallint NULL,
   ResourceEnterpriseText14Indicator         smallint NULL,
   ResourceEnterpriseText15Indicator         smallint NULL,
   ResourceEnterpriseText16Indicator         smallint NULL,
   ResourceEnterpriseText17Indicator         smallint NULL,
   ResourceEnterpriseText18Indicator         smallint NULL,
   ResourceEnterpriseText19Indicator         smallint NULL,
   ResourceEnterpriseText20Indicator         smallint NULL,
   ResourceEnterpriseText21Indicator         smallint NULL,
   ResourceEnterpriseText22Indicator         smallint NULL,
   ResourceEnterpriseText23Indicator         smallint NULL,
   ResourceEnterpriseText24Indicator         smallint NULL,
   ResourceEnterpriseText25Indicator         smallint NULL,
   ResourceEnterpriseText26Indicator         smallint NULL,
   ResourceEnterpriseText27Indicator         smallint NULL,
   ResourceEnterpriseText28Indicator         smallint NULL,
   ResourceEnterpriseText29Indicator         smallint NULL,
   ResourceEnterpriseText30Indicator         smallint NULL,
   ResourceEnterpriseText31Indicator         smallint NULL,
   ResourceEnterpriseText32Indicator         smallint NULL,
   ResourceEnterpriseText33Indicator         smallint NULL,
   ResourceEnterpriseText34Indicator         smallint NULL,
   ResourceEnterpriseText35Indicator         smallint NULL,
   ResourceEnterpriseText36Indicator         smallint NULL,
   ResourceEnterpriseText37Indicator         smallint NULL,
   ResourceEnterpriseText38Indicator         smallint NULL,
   ResourceEnterpriseText39Indicator         smallint NULL,
   ResourceEnterpriseText40Indicator         smallint NULL
)
GO

CREATE TABLE dbo.MSP_VIEW_RES_TP_BY_DAY
(
   ResourceUniqueID                          int NOT NULL,
   ResourceTimeStart                         datetime NULL,
   ResourceTimeFinish                        datetime NULL,
   ResourceTimeWorkAvailability              decimal (25,6) NULL
)
GO

CREATE UNIQUE CLUSTERED INDEX PK_MSP_VIEW_RES_TP_BY_DAY 
ON dbo.MSP_VIEW_RES_TP_BY_DAY(ResourceUniqueID, ResourceTimeStart) 
GO







/*-------------------------------------------------------------------------
 * This tables contains a list of files that can be deleted by the 
 * views scheduling engine
 *------------------------------------------------------------------------*/

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MSP_VIEW_SERVICE_FILE_DELETE_PENDING]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[MSP_VIEW_SERVICE_FILE_DELETE_PENDING]
GO

CREATE TABLE [dbo].[MSP_VIEW_SERVICE_FILE_DELETE_PENDING] (
	[Filename] [ntext] NOT NULL 
) ON [PRIMARY]
GO


/*-------------------------------------------------------------------------
 * This table contains a list of files dropped for processing by the 
 * views scheduling engine
 *------------------------------------------------------------------------*/


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MSP_VIEW_SERVICE_NEW_DROPS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[MSP_VIEW_SERVICE_NEW_DROPS]
GO


CREATE TABLE [dbo].[MSP_VIEW_SERVICE_NEW_DROPS] (
	[Org] [nvarchar] (256) NOT NULL ,
	[Project] [int] NOT NULL ,
	[Filename] [ntext] NOT NULL ,
	[DropTime] [datetime] NOT NULL 
) ON [PRIMARY]
GO


/*-------------------------------------------------------------------------
 * This table contains a list of files dropped for processing by the 
 * views scheduling that are currently undergoing work
 *------------------------------------------------------------------------*/

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MSP_VIEW_SERVICE_PUBLISH_STATUS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[MSP_VIEW_SERVICE_PUBLISH_STATUS]
GO


CREATE TABLE [dbo].[MSP_VIEW_SERVICE_PUBLISH_STATUS] (
	[Org] [nvarchar] (256) NOT NULL ,
	[Project] [int] NOT NULL ,
	[Filename] [ntext] NOT NULL ,
	[DropTime] [datetime] NOT NULL ,
	[Status] [tinyint] NOT NULL 
) ON [PRIMARY]
GO
















