title: Pass multiple parameters using sp_executesql
body: <p>I am using SQL Server 2016 to write a stored procedure with dynamic SQL and <code>sp_executesql</code> with multiple parameters.</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[testsp] @ProductName nvarchar(250), @ProductDescription nvarchar(250)
  AS
  
  DECLARE @query NVARCHAR(MAX)
  
      SET @query = 'EXEC (''INSERT INTO [dbo].[Products] ([ProductName], [ProductDescription]) VALUES (?,?)'', @ProductName, @ProductDescription) AT [linkedserver]' 
    EXEC sp_executesql @sql, N'@ProductName nvarchar(250), @ProductDescription nvarchar(250)', @ProductName, @ProductName;
  </code></pre>
  
  <blockquote>
    <p>Error: Must pass parameter number 2 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'</p>
  </blockquote>
  
  <p>I need to make a jdbc call of the stored procedure.</p>
  
  <pre><code>call [dbo].[testsp](?,?)
  </code></pre>