title: Pass variable as parameter on a Stored Procedure
body: <p>I have a stored procedure with a SELECT statement and two parameters. I want to call this stored procedure from another one that has a variable declared, and use this variable as one of the parameters.</p>
  
  <p>When I try this: </p>
  
  <pre><code>EXEC [dbo].[Testo] @cd_order = 23, @cd_substep = 33
  </code></pre>
  
  <p>It returns some rows as result, but when I try this:</p>
  
  <pre><code>set @temp_var1 = ( Select cd_substep FROM ....Where...)
  
  EXEC [dbo].[Testo] @cd_order = 23, @cd_substep = @temp_var1
  </code></pre>
  
  <p>The result is empty.</p>
  
  <p>The procedure will populate a table variable:</p>
  
  <pre><code>INSERT INTO @Var1Table EXEC [dbo].[Testo] 23, @cd_substep 
  </code></pre>
  
  <p>It's working only when I use a static value. How do I use a variable as a parameter?</p>