title: Need a stored procedure that inserts a row and returns the ID
body: <p>I tried to write a stored procedure that first inserts a new record into table and then returned the id of this new record. I am not sure if it is the correct way and the best way to achieve this.</p>
  
  <pre><code>ALTER PROCEDURE dbo.spAddAsset
  (
  @Name VARCHAR(500),
  @URL VARCHAR(2000)
  )
  AS
  BEGIN
  Set NOCOUNT on;
  
  Insert Into Assets (Name, URL) Values (@Name, @URL)
  
  Declare @new_identity int;
  
  SELECT @new_identity = SCOPE_IDENTITY()
  
  return @new_identity;
  END
  </code></pre>