title: SQL INSERT - FROM 1 Table to another database with aggregate (conditional)
body: <p>Hi i try to search with no luck.
  I need help to Insert a set of records (rows) into another database.
  both database has the same exact column name and exact datatype.</p>
  
  <p>something like this:<br>
      Insert Into A from B
      Where A.columnID &lt;> B.columnID
          AND B.column3 = ' NO'</p>
  
  <p>my code:</p>
  
  <pre><code>INSERT INTO [HOOA].[dbo].[tblPatientInfo]
  SELECT * FROM [MainClinic].[dbo].[tblPatientInfo]
  WHERE [HOOA].[dbo].[tblPatientInfo].AccountID &lt;&gt; [MainClinic].[dbo].tblPatientInfo].AccountID
  AND
  [HOOA].[dbo].[tblPatientInfo].GlobalData = 'NO'
  
  --I TRY THIS AS WELL but no luck
  INSERT INTO [HOOA].[dbo].[tblPatientInfo]
  SELECT * FROM [MainClinic].[dbo].[tblPatientInfo]
  WHERE GlobalData = 'NO'
  AND [HOOA].[dbo].[tblPatientInfo].AccountID &lt;&gt; MainClinic].dbo].tblPatientInfo].AccountID
  </code></pre>