title: Read INSERT output from stored procedure
body: <p>I have a following stored procedure</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[InsertCategory]
    @Name nvarchar(100)
  AS  
  BEGIN 
      INSERT INTO [dbo].[Category]([Name])
      OUTPUT INSERTED.CategoryId, INSERTED.[Timestamp]
      VALUES (@Name)
  END
  </code></pre>
  
  <p>And I call it like this:</p>
  
  <pre><code>EXEC [dbo].[InsertCategory] @Name= @Name
  </code></pre>
  
  <p>I would like to know what the id of inserted Category is (it is output in insert statement). It is written to the output, but I can't figure out how to assign it to a variable without modifying stored procedure. In C# I can use command.ExecuteReader and I get it, but I do not know how to get it in SQL Server.</p>
  
  <p>I also cannot use SCOPE_IDENTITY as we have our own system of generating ids.</p>