title: How to send Array of objects to stored procedure from nodejs express?
body: <p>thanks in advance. Here i want to send a array of objects to the stored procedure via mssql connection to the ms sql-server from NodeJs backend. i have submitted my Stored Procedure and Backend code block.</p>
  <p>--- Stored Procedure ---</p>
  <pre><code>CREATE PROCEDURE [dbo].[AddProductVariant]
  @ProductId BIGINT ,
  @Name NVARCHAR(200) ,
  @InputTypeId TINYINT ,
  @Attributes dbo.UT_ProductVariant READONLY
  AS
  BEGIN
      BEGIN TRY
          SET NOCOUNT ON;
  
          DECLARE @Id BIGINT
          INSERT  INTO dbo.ProductVariants
                  ( ProductId, Name, InputTypeId )
          VALUES  ( @ProductId -- ProductId - bigint
                    , @Name -- Name - nvarchar(50)
                    , @InputTypeId  -- InputTypeId - tinyint
                    )
          SET @Id = SCOPE_IDENTITY()
  
          EXECUTE MergeProductVariantAttributes @Id, @Attributes
  
          SELECT  *
          FROM    SellEasyDb.dbo.ProductVariants
          WHERE   Id = @Id
          --SELECT * FROM SellEasyDb.dbo.UserGroups WHERE SellEasyDb.dbo.UserGroups.Id = @Id
          RETURN 0
      END TRY
  
      BEGIN CATCH
          RETURN @@ERROR
      END CATCH
  
  END
  </code></pre>
  <p>--- NODE TS CODE ---</p>
  <pre><code>    const pool = dbConnect.connect();
      const request = dbConnect.request();
      request.input(&quot;ProductId&quot;, req.body.productId);
      request.input(&quot;Name&quot;, req.body.name);
      request.input(&quot;InputTypeId&quot;, req.body.inputTypeId);
      request.input(&quot;Attributes&quot;, req.body.attributes); // this is the array i want to send to SP
  
      await request.execute(&quot;AddProductVariant&quot;, async (err: any, result: any, resultvalue: any) =&gt; {
          debugger;
          }
      });
  </code></pre>
  <p>--- ERROR ---</p>
  <pre><code>class:16
  code:'EREQUEST'
  lineNumber:0
  message:'Operand type clash: nvarchar is incompatible with UT_ProductVariant'
  name:'RequestError'
  number:206
  state:2
  </code></pre>
  <p>--- User Define Type ---</p>
  <pre><code>CREATE TYPE UT_ProductVariant AS TABLE  
  (  
      [Id] [BIGINT],
      [Title] [VARCHAR](200) NOT NULL,
      [PriceAdjustment] [DECIMAL](18, 2) NOT NULL,
      [IsDefault] [BIT] NOT NULL,
      [SortOrder] [INT] NOT NULL,
      [VarientId] [BIGINT],
      [ProductId] [BIGINT]
  )
  </code></pre>