title: Updating table using merge and use defined table type
body: <p>I have a stored procedure like this</p>
  <pre><code>CREATE PROCEDURE [dbo].[Update_Order]
      @tblOrderProduct [ProductOrderType] READONLY
  AS
  BEGIN
      SET NOCOUNT ON;
    
      MERGE INTO tblKmOrder AS c1
      USING @tblOrderProduct c2 ON c1.id = c2.id 
  
      WHEN MATCHED THEN
          UPDATE 
              SET c1.client = c2.client
  END
  </code></pre>
  <p>and type like this</p>
  <pre><code>CREATE TYPE [dbo].[ProductOrderType] AS TABLE(id int, client nvarchar(max) null)
  </code></pre>
  <p>I am passing datatable as parameter to a stored procedure. The problem is the value are not mapping properly, I am using <code>c1.client = c2.client</code> but <code>c2.client</code> value is not getting mapped; instead id value gets mapped because I pass datatable like this</p>
  <pre><code>id | client 
   1 | somename
  </code></pre>
  <p>and I pass like this</p>
  <pre><code>cmd.Parameters.AddWithValue(&quot;@&quot; + parameter, dt);
  </code></pre>
  <p>Why does this fail?</p>