title: User-defined table type with column Id as Identity(1,1)
body: <p>I am using a user-defined table type as parameter in a procedure and that user defined table has a column <code>Id</code> which has the <code>identity</code> flag set.</p>
  
  <p>Problem:</p>
  
  <pre><code>CREATE TYPE [dbo].[UdtTable] AS TABLE
                                  (
                                      [Id] [INT] IDENTITY(1, 1),
                                      [StudentId] [INT] NOT NULL
                                  )
  </code></pre>
  
  <p>When executing my procedure in SQL Server directly, it's working, but when I am calling this procedure from C# code, it's not working but it's also not showing any errors.</p>
  
  <p>This query runs fine:</p>
  
  <pre><code>DECLARE @TableUDT [UdtTable];
  
  INSERT INTO @TableUDT 
      SELECT 201;
  
  INSERT INTO @TableUDT 
      SELECT 202;
  
  EXEC MYProcName @TableUDT
  </code></pre>
  
  <p>But this isn't working:</p>
  
  <pre><code>DataTable udtDataTable = new DataTable();
  udtDataTable.Columns.Add("StudentId");
  
  
  DataRow dRow = udtDataTable.NewRow();
  dRow["StudentId"] = 201
  udtDataTable.Rows.Add(dRow)
  
  DataRow dRow2 = udtDataTable.NewRow();
  dRow2["StudentId"] = 201
  udtDataTable.Rows.Add(dRow2)
  
  List&lt;SqlParameter&gt; parameters = new List&lt;SqlParameter&gt;();
  parameters.Add(new SqlParameter("@TableLeaveID", udtDataTable));
  
  DataTable = new DML.RunProcedure("MyProcName",parameters);
  </code></pre>
  
  <p><strong>Note</strong>: according to my procedure it should return a table.</p>