Assuming SQL Server 2008 or newer, in SQL Server, create a table type once:
CREATE TYPE dbo.ColumnBValues AS TABLE
(
ColumnB INT
);
Then a stored procedure that takes such a type as input:
CREATE PROCEDURE dbo.whatever
@ColumnBValues dbo.ColumnBValues READONLY
AS
BEGIN
SET NOCOUNT ON;
SELECT A.* FROM dbo.TableA AS A
INNER JOIN @ColumnBValues AS c
ON A.ColumnB = c.ColumnB;
END
GO
Now in C#, create a DataTable and pass that as a parameter to the stored procedure:
DataTable cbv = new DataTable();
cbv.Columns.Add(new DataColumn("ColumnB"));
// in a loop from a collection, presumably:
cbv.Rows.Add(someThing.someValue);
using (connectionObject)
{
SqlCommand cmd = new SqlCommand("dbo.whatever", connectionObject);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter cbvParam = cmd.Parameters.AddWithValue("@ColumnBValues", cbv);
cbvParam.SqlDbType = SqlDbType.Structured;
//cmd.Execute...;
}
(You might want to make the type a lot more generic, I named it specifically to make it clear what it is doing.)