Error: The "%1" has a length that is not valid. The length must be between %2!ld! and %3!ld!

Sometimes, while making adjustments to the data type length on the Columns tab of the ZappySys component, you may encounter the following error:

Failed to save column [Details, DataType=DT_WSTR, Length=8000]. Error: The “%1” has a length that is not valid. The length must be between %2!ld! and %3!ld!.

Exception from HRESULT: 0xC0204016

Cause

You are attempting to assign a length that exceeds the allowable limit for the data type columns. In the upper scenario, the error occurs when attempting to set the length of a DT_WSTR data type column to 8000 within the ZappySys Component on the Columns tab. However, the allowed maximum length for the DT_WSTR data type is 4000, and exceeding this limit triggers the error.

To address this issue

To address this error, consider selecting a more accommodating data type with a larger storage capacity, such as choosing ‘ntext’
In the upper scenario, consider selecting a higher-length data type, such as DT_NTEXT, which accommodates lengths beyond 4000 characters. This adjustment should align with the requirements of your data and prevent the specified error related to the DT_WSTR length limitation.

n SQL Server Integration Services (SSIS), the data types and their maximum lengths can vary depending on the specific requirements and versions of SSIS. Below is a list of commonly used SSIS data types along with their typical maximum lengths:

  1. DT_STR (AnsiString):
    • Maximum length: 8000 characters
  2. DT_WSTR (UnicodeString):
    • Maximum length: 4000 characters
  3. DT_TEXT (LongAnsiString):
    • Maximum length: 2^31-1 (2,147,483,647) characters
  4. DT_NTEXT (LongUnicodeString):
    • Maximum length: 2^30 - 1 (1,073,741,823) characters
  5. DT_BYTES (Binary):
    • Maximum length: 8000 bytes
  6. DT_DECIMAL (Decimal):
    • Precision: 28 digits
    • Scale: 4
  7. DT_NUMERIC (Numeric):
    • Precision: 28 digits
    • Scale: 4

These examples represent only a subset of the data types supported by SSIS. A comprehensive list of available data types can be found here.