You can try defining length at runtime or use -1.
static void CreateSqlParameterSize()
{
string description = "12 foot scarf - multiple colors, one previous owner";
SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar);
parameter.Direction = ParameterDirection.InputOutput;
parameter.Size = description.Length;
parameter.Value = description;
}
Reference:
SqlParameter.Size Property (System.Data.SqlClient) | Microsoft Docs[
^]
Quote:
if the NVARCHAR parameter has MAX data length, Simply set it as -1. -1 is the magic number for this data length.
Ex:
SqlParameter param = new SqlParameter("@value", SqlDbType.NVarChar, -1);