title: SQL can't insert data for time dimension table
body: <p>I am building a Data warehouse for my school project. I have already created my time dimension table and it works. </p>
  
  <pre><code>`  CREATE TABLE TimeDim(
     [timeCode] int primary key,
     [date] datetime,
     [year] char(4),
     [month] varchar(2),
     [monthName] varchar(9),
     [Quarter] varchar(9),
     [dayOfMonth] varchar(2),
     [dayName] varchar(9),
     [dayOfQuarter] varchar(3),
     [dayOfYear] varchar(3),
     [weekOfMonth] varchar(1),
     [weekOfQuarter] varchar(2),
     [weekOfYear] varchar(2));`
  </code></pre>
  
  <p>However, the errors occur when I try to create data in the Time Dimension table.The error shows: **</p>
  
  <pre><code>`Msg 213, Level 16, State 1, Line 95
  Column name or number of supplied values does not match table definition.`
  </code></pre>
  
  <p>**
  The code for me to create data is </p>
  
  <pre><code> DECLARE @StartDate DATETIME = '01/01/2003' --Starting value of Date Range
  DECLARE @EndDate DATETIME = '01/01/2006' --End Value of Date Range ( end at 31/12/1999)
  
  --Temporary Variables To Hold the Values During Processing of Each Date of Year
  DECLARE
      @DayOfWeekInMonth INT,
      @DayOfWeekInYear INT,
      @DayOfQuarter INT,
      @WeekOfMonth INT,
      @CurrentYear INT,
      @CurrentMonth INT,
      @CurrentQuarter INT
  
  /*Table Data type to store the day of week count for the month and year*/
  DECLARE @DayOfWeek TABLE (DOW INT, MonthCount INT, QuarterCount INT, YearCount INT)
  
  INSERT INTO @DayOfWeek VALUES (1, 0, 0, 0)
  INSERT INTO @DayOfWeek VALUES (2, 0, 0, 0)
  INSERT INTO @DayOfWeek VALUES (3, 0, 0, 0)
  INSERT INTO @DayOfWeek VALUES (4, 0, 0, 0)
  INSERT INTO @DayOfWeek VALUES (5, 0, 0, 0)
  INSERT INTO @DayOfWeek VALUES (6, 0, 0, 0)
  INSERT INTO @DayOfWeek VALUES (7, 0, 0, 0)
  
  --Extract and assign various parts of Values from Current Date to Variable
  
  DECLARE @CurrentDate AS DATETIME = @StartDate
  SET @CurrentMonth = DATEPART(MM, @CurrentDate)
  SET @CurrentYear = DATEPART(YY, @CurrentDate)
  SET @CurrentQuarter = DATEPART(QQ, @CurrentDate)
  
  /********************************************************************************************/
  --Proceed only if Start Date(Current date ) is less than End date you specified above
  
  WHILE @CurrentDate &lt; @EndDate
  BEGIN
  
  /*Begin day of week logic*/
  
           /*Check for Change in Month of the Current date if Month changed then 
            Change variable value*/
      IF @CurrentMonth != DATEPART(MM, @CurrentDate) 
      BEGIN
          UPDATE @DayOfWeek
          SET MonthCount = 0
          SET @CurrentMonth = DATEPART(MM, @CurrentDate)
      END
  
          /* Check for Change in Quarter of the Current date if Quarter changed then change 
           Variable value*/
  
      IF @CurrentQuarter != DATEPART(QQ, @CurrentDate)
      BEGIN
          UPDATE @DayOfWeek
          SET QuarterCount = 0
          SET @CurrentQuarter = DATEPART(QQ, @CurrentDate)
      END
  
          /* Check for Change in Year of the Current date if Year changed then change 
           Variable value*/
  
  
      IF @CurrentYear != DATEPART(YY, @CurrentDate)
      BEGIN
          UPDATE @DayOfWeek
          SET YearCount = 0
          SET @CurrentYear = DATEPART(YY, @CurrentDate)
      END
  
          -- Set values in table data type created above from variables 
  
      UPDATE @DayOfWeek
      SET 
          MonthCount = MonthCount + 1,
          QuarterCount = QuarterCount + 1,
          YearCount = YearCount + 1
      WHERE DOW = DATEPART(DW, @CurrentDate)
  
      SELECT
          @DayOfWeekInMonth = MonthCount,
          @DayOfQuarter = QuarterCount,
          @DayOfWeekInYear = YearCount
      FROM @DayOfWeek
      WHERE DOW = DATEPART(DW, @CurrentDate)
  
  /*End day of week logic*/
  
  
  /* Populate Your Dimension Table with values*/
  
      INSERT INTO [dbo].[TimeDim]
      SELECT
  
          CONVERT (char(8),@CurrentDate,112) as timeCode,
          @CurrentDate AS date,
          CONVERT (char(10),@CurrentDate,103) as FullDateUK,
          CONVERT (char(10),@CurrentDate,101) as FullDateUSA,
          DATEPART(DD, @CurrentDate) AS dayOfMonth,
          --Apply Suffix values like 1st, 2nd 3rd etc..   
          DATENAME(DW, @CurrentDate) AS dayName,  
          @DayOfQuarter AS dayOfQuarter,
          DATEPART(DY, @CurrentDate) AS dayOfYear,
          DATEPART(WW, @CurrentDate) + 1 - DATEPART(WW, CONVERT(VARCHAR, 
          DATEPART(MM, @CurrentDate)) + '/1/' + CONVERT(VARCHAR, 
          DATEPART(YY, @CurrentDate))) AS weekOfMonth,
          (DATEDIFF(DD, DATEADD(QQ, DATEDIFF(QQ, 0, @CurrentDate), 0), 
          @CurrentDate) / 7) + 1 AS weekOfQuarter,
          DATEPART(WW, @CurrentDate) AS weekOfYear,
          DATEPART(MM, @CurrentDate) AS month,
          DATENAME(MM, @CurrentDate) AS monthName,
  
          DATEPART(QQ, @CurrentDate) AS Quarter,
  
          DATEPART(YEAR, @CurrentDate) AS year
  
  
      SET @CurrentDate = DATEADD(DD, 1, @CurrentDate)
  END
  </code></pre>