title: Must declare the scalar variable
body: <p><code>@RowFrom int</code></p>
  
  <p><code>@RowTo int</code></p>
  
  <p>are both Global Input Params for the Stored Procedure, and since I am compiling the SQL query inside the Stored Procedure with T-SQL then using <code>Exec(@sqlstatement)</code> at the end of the stored procedure to show the result, it gives me this error when I try to use the <code>@RowFrom</code> or <code>@RowTo</code> inside the <code>@sqlstatement</code> variable that is executed.. it works fine otherwise.. please help.</p>
  
  <pre><code>"Must declare the scalar variable "@RowFrom"."
  </code></pre>
  
  <hr>
  
  <p>Also, I tried including the following in the <code>@sqlstatement</code> variable:</p>
  
  <pre><code>'Declare @Rt int'
  'SET @Rt = ' + @RowTo
  </code></pre>
  
  <p>but <code>@RowTo</code> still doesn't pass its value to <code>@Rt</code>  and generates an error.</p>