title: Multiple IF statements in Delete Trigger
body: <p>I'm trying to create the following logic in a SQL Server trigger:</p>
  
  <ol>
  <li>Check if Deleted.ProfID = 3</li>
  <li>If Yes, check if there are not any records in tblPartLic with ProfID = 3, then </li>
  <li>If not, Insert into tblParticipantLicense a not licensed 3 record<br>
  --    a. idsNumber, txtEmailAddress, state = 70 state</li>
  </ol>
  
  <p>I tried:</p>
  
  <pre><code>IF (deleted.idsProf = 3)
  BEGIN
  
      IF NOT Exists(Select PL.idsNumber FROM tblPartLic PL INNER JOIN Deleted D 
          ON PL.idsNumber=D.idsNumber 
          WHERE PL.idsProfession = 3 AND PL.idsState &lt;&gt; 70)
      BEGIN
  
          INSERT INTO tblPartLic (idsNumber, txtLicNumber, txtState, txtProfOrg, 
                  idsCountry, idsState, idsProf)
              SELECT Deleted.idsDASNumber, 'AR NL', 'NL', 'Architect', 208, 70, 3
              FROM Deleted 
  
      END;
  END;            
  </code></pre>