title: SQL Server - copy and modify a year's data
body: <p>In need of a guide here.
  I have a set of records for the year 2019, the entire 365 days, that I need to make some updates with. The things that I need to do are:</p>
  
  <ol>
  <li>Update a column from another column in the table. So the staffing_date column = date.</li>
  <li>Make a copy of the records into the same table.</li>
  <li>Update a column with either "Day" or "Night". 1 day would have two records - one for "day" and one for "night"</li>
  <li>Update a column based on the values from other columns, i.e. if it is"day" and "weekday" then the leave_num = 38. If it's "night" and weekend" then the leave num = 33.</li>
  </ol>
  
  <p>Examples of data:</p>
  
  <pre><code>Staffing_date   day_night caldendar_year    date     weekend_ind  month leave_num   
  NULL            NULL         2019        2019-01-01   WEEKDAY      1     NULL  
  NULL            NULL         2019        2019-01-02   WEEKDAY      1     NULL
  NULL            NULL         2019        2019-01-12   WEEKEND      1     NULL
  </code></pre>
  
  <p>Staffing_date needs to be updated with the date in the same row. I think I can figure this part out, but for the rest, I am not sure what will be the best way to go about it? </p>
  
  <p>For #3, I'm trying to use the CROSS APPLY as suggested below, but I don't think I'm using it right. </p>
  
  <pre><code>insert into mytable (day_night)
  select days
  from mytable
  CROSS APPLY (
  values('day'), ('night')) v(days)
  where calendar_year = '2019'
  </code></pre>