Puede crear un tipo de tabla y pasar los valores a través de ella, así:
CREATE TYPE Suite_Lease AS TABLE
(
suite_id varchar(15) NOT NULL,
lease_id varchar(15) NOT NULL
)
GO
CREATE PROC DoUpdate
@Params Suite_Lease READONLY,
@uplift varchar(15),
@code varchar(15)
AS
update property.lease_period set
scca_uplift = @uplift,
scca_notes_code = @code
from property.lease_period tab
JOIN @params filt
on tab.suite_id=filt.suite_id AND tab.lease_id=filt.lease_id
Esto mantendrá su caché de procedimientos seco y limpio, en cambio, si usa varias cláusulas "grandes" donde
Cómo pasar el parámetro de la tabla al procedimiento almacenado (C#):
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("suite_id", typeof (string)) {AllowDBNull = false, MaxLength = 15});
dt.Columns.Add(new DataColumn("lease_id", typeof (string)) {AllowDBNull = false, MaxLength = 15});
dt.Rows.Add("CCBG08", "205059");
... add more rows for match
using (var c = new SqlConnection("ConnectionString"))
{
c.Open();
using(var sc = c.CreateCommand())
{
sc.CommandText = "DoUpdate";
sc.CommandType = CommandType.StoredProcedure;
sc.Parameters.AddWithValue("@uplift", "110");
sc.Parameters.AddWithValue("@code", "21006");
sc.Parameters.Add(new SqlParameter("@Params", SqlDbType.Structured) { TypeName = null, Value = dt });
sc.ExecuteNonQuery();
}
}