title: Modify query to use INSERT INTO
body: <p>I have developed a pretty complicated query, and now have hard time modifying it to use INSERT INTO statement. </p>
  
  <p>The query (VS syntax):</p>
  
  <pre><code>           @"SELECT s.TagID, se.SessionID, " +
             " @todaysDate " +
             " AS ScanningTime " +
             " FROM (((Student s " +
             " LEFT JOIN [CourseID-ModuleID] cm ON s.CourseID = cm.CourseID) " +
             " LEFT JOIN [ModuleID-SessionID] ms ON cm.ModuleID = ms.ModuleID) " +
             " LEFT JOIN [Session] se ON ms.SessionID = se.SessionID) " +
             " WHERE s.TagID = @tagNo " +
             " AND se.SessionDate = cast(getdate() as date) " +
             " AND se.SessionTimeStart &lt;= @Plus30Min " +
             " AND se.SessionTimeEnd &gt;= @Plus30Min ";
  </code></pre>
  
  <p>The query runs perfectly, but I would like to place the result of the query into the empty table <code>Attendance</code>, which already exists in the DB.</p>
  
  <pre><code>Attendance table data types
  
  TagID - int
  SessionID - varchar
  ScanningTime - datetime.
  </code></pre>
  
  <p>Please note that data types for Attendance table match with other tables data types.</p>
  
  <p>I have tried placing "INSERT INTO Attendance (s.TagID, se.SessionID, ScanningTime)" just before the SELECT statement, but then my query does not produce any results.</p>
  
  <p>What is a proper way to modify my query to include INSERT INTO statement? Thanks</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>All your answers and suggestions where very helpful. Thank you!</p>