Execute stored procedure that has parameters with sp_executesql
<p>I have a simple stored procedure that has parameter</p>

<pre><code>CREATE Procedure GetSupplierForTesting
    (@SupplierId INT)
AS
    SELECT SuppLabel 
    FROM Supplier 
    WHERE Supplier.SupplierId = @SupplierId
</code></pre>

<p>I am able to call it with the exec command inside another stored procedure like this </p>

<pre><code>exec GetSupplierForTesting @SupplierId = 10
</code></pre>

<p>I came across an article that explains how <code>sp_executesql</code> is faster than <code>exec</code>. My problem is that I don't know how to call a stored procedure that has parameters with <code>sp_executesql</code>. I have tried this code </p>

<pre><code>DECLARE @SupplierId INT = 10;
EXEC sp_executesql N'GetSupplierForTesting', N'@SupplierId INT', @SupplierId
</code></pre>

<p>but I am getting an error: </p>

<blockquote>
  <p>Procedure or function 'GetSupplierForTesting' expects parameter '@SupplierId', which was not supplied</p>
</blockquote>