title: Update followed by insert in a stored procedure
body: <p>I'm not sure that's the correct way making an update followed by insert in a stored procedure.</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  CREATE PROCEDURE [dbo].[io_sp_admin_add_emp]
      @id BIGINT,
      @lastName VARCHAR(20), 
      @firstName VARCHAR(20)
  AS
  BEGIN
      SET NOCOUNT ON;
  
      BEGIN TRY
      BEGIN TRANSACTION [TranAddEmp]
         DECLARE @identity BIGINT = 0 
  
         INSERT INTO empTable(LastName, FirstName, hash_id)
         VALUES (@lastName, @firstName,
                 HashBytes('SHA2_256', CAST(@id AS VARBINARY(50))))
  
         SELECT @identity = @@identity
  
         UPDATE empTable
         SET rowId = incId  -- both are columns in empTable
         WHERE hash_id = @identity
  
         COMMIT TRANSACTION [TranAddEmp]   
      END TRY
      BEGIN CATCH
          ROLLBACK TRANSACTION [TranAddEmp]
      END CATCH                  
  END
  </code></pre>