title: How to retrieve out parameter using text command
body: <p>I need to find a way to retrieve out parameter for the following query:</p>
  
  <pre><code>query = @"declare @p7 int
            exec some_sproc @SomeArg=@p7
            select @p7";
  
  sqlCommand.CommandText = query;
  sqlCommand.CommandType = CommandType.Text;
  </code></pre>
  
  <p>I tired with adding SQL paramater but then the whole code was simply wrapped with <code>exec sp_executesql</code> and the parameter was added. This simply doesn't work. Do you know how I could get value of @p7 on C# side?</p>
  
  <p>My stored procedure uses table valued parameters, however by default it is evaluated to </p>
  
  <pre><code>declare @p11 acco.SomeUDT
  insert into @p11 values(1,'2017-06-15 00:00:00',64.73)
  insert into @p11 values(1,'2017-06-15 00:00:00',1.30)
  </code></pre>
  
  <p>But my intention is to get following syntax:</p>
  
  <pre><code>declare @p11 acco.SomeUDT
  insert into @p11 values(1,'2017-06-15 00:00:00',64.73), (1,'2017-06-15 00:00:00',1.30)
  </code></pre>
  
  <p>This is why I build manually SQL code. So we have:</p>
  
  <pre><code>query = @"declare @p7 int
  
            declare @p11 acco.SomeUDT
            insert into @p11 values(1,'2017-06-15 00:00:00',64.73), (1,'2017-06-15 00:00:00',1.30)
  
            exec some_sproc @SomeArg=@p7, @SomeUDTArg=@p11
            select @p7";
  sqlCommand.CommandText = query;
  sqlCommand.CommandType = CommandType.Text;
  </code></pre>
  
  <p>If I use stored procedure type and SQL parameters than I get first syntax.</p>
  
  <p>All works but I need to map also out parameter @SomeArg and I have problem with this.</p>