title: Specify the parameter values part of sp_executeSQL as a parameter
body: <p>I am using SQL Server 2008 R2. <strong>I need to use a parameter for the last part of T-SQL below.</strong></p>
  
  <p>In this part, the values of parameters to sp_executesql are specified, but I want to supply it dynamically.</p>
  
  <pre><code>EXECUTE sp_executesql @sql,N'@startIndex1 int,@maxRows1 int',
                        @startIndex1 = @startIndex,@maxRows1 = @maxRows--LAST PART
  </code></pre>