title: SQL Server - BEFORE INSERT Trigger
body: <p>I have two tables as follows:</p>
  
  <p>Table 1 'MySkills' [ primary key (EmpId, SkillId)]</p>
  
  <pre><code>+----------+------------+---------+----------+-----------+------------+-----------------+----------------+
  |  EmpId   | CategoryId | SkillId | ExpYears | ExpMonths | Experience | RatingSubmitted | RatingApproved |
  +----------+------------+---------+----------+-----------+------------+-----------------+----------------+
  | CSSL9610 | arcgis     | arcgis1 | 0.00     | 0.00      | 0.00       | 1.00            | NULL           |
  | CSSL9610 | arcgis     | arcgis2 | 0.00     | 0.00      | 0.00       | 0.00            | NULL           |
  | CSSL9610 | arcgis     | arcgis3 | 0.00     | 0.00      | 0.00       | 0.00            | NULL           |
  | CSSL9610 | arcgis     | arcgis4 | 0.00     | 0.00      | 0.00       | 0.00            | NULL           |
  | CSSL9610 | arcgis     | arcgis5 | 0.00     | 0.00      | 0.00       | 0.00            | NULL           |
  | CSSL9610 | arcgis     | arcgis6 | 0.00     | 0.00      | 0.00       | 0.00            | NULL           |
  | CSSL9610 | arcgis     | arcgis7 | 0.00     | 0.00      | 0.00       | 0.00            | NULL           |
  +----------+------------+---------+----------+-----------+------------+-----------------+----------------+
  </code></pre>
  
  <p>And Table 1 'MySkills_details' [ primary key (EmpId)]</p>
  
  <pre><code>+-------+------------------+---------------+----------------+--------+---------------+---------+------------+
  | EmpId | Experience_Prior | Qualification | Specialization | Status | LastSubmitted | NextDue | ApprovedOn |
  +-------+------------------+---------------+----------------+--------+---------------+---------+------------+
  </code></pre>
  
  <p>Right now, there is no data in MySkills_details. 
  I have to make a Foreign key on EmpId in MySkills_details referencing EmpId in MySkills, which is not possible due to composite primary key in MySkills.
  So I decided to go the other way round. Except the insertion is happening in MySkills first and there are no BEFORE INSERT triggers in SQL Server as far as I know.
  So, How to write a trigger like BEFORE INSERT which inserts data in MySkill_details first before inserting in MySkills.</p>