title: Using SCOPE_IDENTITY multiple times for multiple tables
body: <p>Is this okay to use SCOPE_IDENTITY() multiple times within one store procedure? Is there any chance of getting wrong SCOPE_IDENTITY value?</p>
  
  <p>In the sp, there are three different insert statements for three different tables, table A SCOPE_IDENTITY value is passed into table B and table B SCOPE_IDENTITY value is passed into table C. </p>
  
  <p>I am saving SCOPE_IDENTITY value into variable first </p>
  
  <pre><code>SET @EmpID = SCOPE_IDENTITY();
  </code></pre>
  
  <p>and then passing @EmpID into insert statement.</p>
  
  <p>Is there any risk of using SCOPE_IDENTITY() multiple times?</p>
  
  <p>Also, i think SCOPE_IDENTITY is the best option for me as;</p>
  
  <p>•IDENT_CURRENT returns the last identity value generated for a specific table in any session and any scope.</p>
  
  <p>•@@IDENTITY returns the last identity value generated for any table in the current session, across all scopes.</p>
  
  <p>•SCOPE_IDENTITY returns the last identity value generated for any table in the current session and the current scope.</p>