title: How to insert values into two tables with a foreign key relationship?
body: <p>I created two tables:</p>
  
  <ul>
  <li><p>Table <code>tblStaff</code> with columns <code>id</code> (primary key, auto increment), <code>name</code>, <code>age</code>, <code>address</code></p></li>
  <li><p>Table <code>tblRoleOfStaff</code> with columns <code>id</code> (primary key, auto increment), <code>StaffId</code> (foreign key to <code>tblStaff</code>), <code>RoleId</code></p></li>
  </ul>
  
  <p>I have form to create new staff with existing role. Data sample to insert: </p>
  
  <pre><code>(name, age, address, roleId) = ('my name',20,'San Jose', 1)
  </code></pre>
  
  <p>I want to write a stored procedure in SQL Server 2014 to insert new staff to <code>tblStaff</code> and insert new record into <code>tbleRoleOfStaff</code> with <code>staffId</code> I just inserted.</p>
  
  <p>What should I do?</p>
  
  <p>I am so sorry if my question is duplicate with other. I am fresher in SQL.
  Thanks for any help.</p>