-- Ensure you've run Item55StructureAndData.sql in the 
-- Sample Databases folder in order to run this example. 

USE Item55Example;
GO

--NOTE: This is already created if you run the Item55StructureAndData in the sample database folder.

CREATE TABLE DimDate (
  DateKey int NOT NULL,
  DateValue date NOT NULL PRIMARY KEY,
  NextDayValue date NOT NULL,
  YearValue smallint NOT NULL,
  YearQuarter int NOT NULL,
  YearMonth int NOT NULL,
  YearDayOfYear int NOT NULL,
  QuarterValue tinyint NOT NULL,
  MonthValue tinyint NOT NULL,
  DayOfYear smallint NOT NULL,
  DayOfMonth smallint NOT NULL,
  DayOfWeek tinyint NOT NULL,
  YearName varchar(4) NOT NULL,
  YearQuarterName varchar(7) NOT NULL,
  QuarterName varchar(8) NOT NULL,
  MonthName varchar(3) NOT NULL,
  MonthNameLong varchar(9) NOT NULL,
  WeekdayName varchar(3) NOT NULL,
  WeekDayNameLong varchar(9) NOT NULL,
  StartOfYearDate date NOT NULL,
  EndOfYearDate date NOT NULL,
  StartOfQuarterDate date NOT NULL,
  EndOfQuarterDate date NOT NULL,
  StartOfMonthDate date NOT NULL,
  EndOfMonthDate date NOT NULL,
  StartOfWeekStartingSunDate date NOT NULL,
  EndOfWeekStartingSunDate date NOT NULL,
  StartOfWeekStartingMonDate date NOT NULL,
  EndOfWeekStartingMonDate date NOT NULL,
  StartOfWeekStartingTueDate date NOT NULL,
  EndOfWeekStartingTueDate date NOT NULL,
  StartOfWeekStartingWedDate date NOT NULL,
  EndOfWeekStartingWedDate date NOT NULL,
  StartOfWeekStartingThuDate date NOT NULL,
  EndOfWeekStartingThuDate date NOT NULL,
  StartOfWeekStartingFriDate date NOT NULL,
  EndOfWeekStartingFriDate date NOT NULL,
  StartOfWeekStartingSatDate date NOT NULL,
  EndOfWeekStartingSatDate date NOT NULL,
  QuarterSeqNo int NOT NULL,
  MonthSeqNo int NOT NULL,
  WeekStartingSunSeq int NOT NULL,
  WeekStartingMonSeq int NOT NULL,
  WeekStartingTueSeq int NOT NULL,
  WeekStartingWedSeq int NOT NULL,
  WeekStartingThuSeq int NOT NULL,
  WeekStartingFriSeq int NOT NULL,
  WeekStartingSatSeq int NOT NULL,
  JulianDate int NOT NULL,
  ModifiedJulianDate int NOT NULL,
  ISODate varchar(10) NOT NULL,
  ISOYearWeekNo int NOT NULL,
  ISOWeekNo smallint NOT NULL,
  ISODayOfWeek tinyint NOT NULL,
  ISOYearWeekName varchar(8) NOT NULL,
  ISOYearWeekDayOfWeekName varchar(10) NOT NULL
);