Question: I already read many posts about this topic. 

I'm trying to perform on a real table the following:

```
DELETE FROM MYTABLE WHERE ID in (...)

```

where *in* clause can contain 1,2 or many (>3000) values (deriving from a list in c#)

I haven't problems about triggers, FK...

I can't find a complete sample using temporary table table value, or type.
And I can't understand how can I insert (3000 records) in the temp table/table value/type without having performance problems. I already understand to do the join after.

I would avoid Stored Procedure if possible

Answer: 
Please see [Pass table valued parameter using ADO.Net](https://stackoverflow.com/a/10409710/1260204), that is where this answer was derived from.

1. **Create type in SQL Server**:

```
CREATE TYPE [dbo].[MyDataType] As Table
(
    cust_id INT
)

```
2. **Create DataTable in C#**:

```
DataTable myDataTable = new DataTable("dbo.MyDataType");
myDataTable.Columns.Add("cust_id", typeof(Int32));
myDataTable.Rows.Add(1);
myDataTable.Rows.Add(2);

```
3. **Create SQL Parameter and execute query**:

```
using(var command = new SqlCommand(connection, "DELETE FROM MYTABLE WHERE EXISTS (SELECT 1 FROM @myData WHERE cust_id = ID)"))
{       
  SqlParameter parameter = new SqlParameter();
  parameter.ParameterName = "@myData";
  parameter.SqlDbType = System.Data.SqlDbType.Structured;
  parameter.Value = myDataTable;
  command.Parameters.Add(parameter);

  // execute delete
  command.ExecuteNonQuery();
}

```
Step 1: Create table variable

```
CREATE TYPE SampleTable AS TABLE
(
        Id INT  
)
GO

```

Step 2: Insert your table variable from your C# List

Step 3: Delete your table data

```
DECLARE @Sample_Id_List SampleTable READONLY
DELETE FROM YourTable WHERE Id IN (SELECT Id FROM @Sample_Id_List)

```