title: The multi-part identifier "field" could not be bound
body: <p>I'm trying to use data stored in a temporary result set (SOURCE in the code) to fill another table with SQL Server 2012. When executing the below code I get the error "The multi-part identifier "SOURCE.JnlDetoaId" could not be bound".</p>
  
  <pre><code>SELECT Journaldet.*, Agency.ID_Agency INTO SOURCE
  FROM Journaldet 
  inner join Agency 
  ON Agency.Agency_ID = Journaldet.AgenceId
  
  IF  ((SELECT COUNT(Journal.Journal_ID) FROM dbo.Journal, SOURCE WHERE Journal_ID =      SOURCE.JournalId)=0)
  INSERT INTO Discarded.JournalDet(JournalDet_ID, Amount, Sensoa, DetoaId,    ID_Agency, JournalId, Appli_Source, ReasonDiscarded, DateDiscarded) 
  VALUES (SOURCE.JnlDetoaId, SOURCE.Amount, SOURCE.Sensoa, SOURCE.DetoaId,    SOURCE.ID_Agency, JournalId, 'GameApps','Member not yet inserted', GETDATE());
  </code></pre>
  
  <p>I read some threads about here but didn't see how to apply them to my case.
  Any help please?</p>