title: Stored procedure output parameter using sp_executesql returning null
body: <p>I'm trying to determine why a db call in .Net is failing with an output parameter.  I'm using <a href="https://github.com/StackExchange/dapper-dot-net" rel="nofollow">Dapper</a> ORM to make the call and this is a bare bones sample of the trace.  It uses <code>sp_executesql</code> to parametrize the call and I think there lies the problem with the output parameter.</p>
  
  <p>Consider this code:</p>
  
  <pre><code>CREATE PROC test
      @addressId INT = NULL OUTPUT
  AS
      -- using select and set to see if if makes a difference using either
      select @addressId = 1
      SET @addressId = 1
  GO
  
  declare @p3 int
  set @p3=NULL
  exec sp_executesql N'test',N'@addressId int output',@addressId=@p3 output
  select @p3
  </code></pre>
  
  <p>I would expect <code>select @p3</code> to return 1, why does it return null?</p>