title: Inserting Multiple Rows into Table based on Number of Rows in Another
body: <p>I am trying to insert rows into the Attendance_Check Table based on the number of Students in the related class. For every student in the class, they should have a row in the attendance_check table.</p>
  
  <p>Relevant Tables include: Attendance_Record, Att_Check, Student, and Class </p>
  
  <pre><code>declare @i int;
  
  /* 1. Create a new Record for specified class and date*/
  
  INSERT INTO Attendance_Record (Class_ID, Att_Date)
  VALUES('1', GETDATE()); /* insert class_ID for the class the teacher is recording attendance for)*/
  
  SELECT @i= SCOPE_IDENTITY();
  
  INSERT INTO Att_Check (Att_ID, Stu_ID)
  VALUES((SELECT @i), (SELECT S.Stu_ID
          FROM Student S
              INNER JOIN Class C
                  ON S.Class_ID=C.Class_ID
          WHERE C.Class_ID='1'))
  </code></pre>
  
  <p>This code is attempting to populate the attendance_check tables with both the attendance id that correlates to class 1 and the students belonging to class 1.</p>
  
  <p>At the current time, this only gives me an error that the Subquery returned more than one value. I do understand why that is, but I am having trouble thinking about how to rewrite the code to get around it. I'd like the results to end up like so: </p>
  
  <pre><code>Attendance Record Table
  Att_ID | Class_ID | Date
  1          1         10/10/2019
  
  
  Attendance Check Table
  Att_ID| Stu_ID | Stu_Status
  1        1
  1        2   
  1        3
  
  </code></pre>