title: Azure data factory and stored procedure
body: <p>I've got problem with Azure Data Factory and Stored Procedure. </p>
  
  <p>I've set SP as sink for input data:</p>
  
  <pre><code>"sink": {
                          "type": "SqlSink",
                  "sqlWriterStoredProcedureName": "spAddProducts",
                      "storedProcedureParameters": {
                          "stringProductData": {
                              "value": "str1"
                          }
                      },
  </code></pre>
  
  <p>and after execution I've got to process about 200k records, but after some limited number of processed rows (about 10k), I've got error:</p>
  
  <pre><code>Copy activity met invalid parameters:
  ErrorCode=InvalidParameter,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,
  Message=The value of the property '' is invalid: 'The SqlParameter is already contained by another
  SqlParameterCollection.'.,Source=,''Type=System.ArgumentException,
  Message=The SqlParameter is already contained by another SqlParameterCollection.,Source=System.Data,'.
  </code></pre>
  
  <p>SP code:</p>
  
  <pre><code>CREATE PROCEDURE spAddProducts @DimProducts [dbo].[ProductsType] READONLY, @stringProductData varchar(256)
  AS
  BEGIN
  
  MERGE [dbo].[DimProducts] AS tpr
      USING @DimProducts AS spr
      ON tpr.ID = spr.ID
  WHEN MATCHED AND (tpr.Name &lt;&gt; spr.Name OR tpr.NameInternational &lt;&gt; spr.NameInternational OR tpr.ProductType &lt;&gt; spr.ProductType) THEN 
      UPDATE SET tpr.Name = spr.Name, tpr.NameInternational = spr.NameInternational, tpr.ProductType = spr.ProductType
  WHEN NOT MATCHED THEN 
      INSERT (Name, NameInternational, ProductType, ID) 
      VALUES(spr.Name, spr.NameInternational, spr.ProductType, spr.ID)
  ;
  END
  </code></pre>