Maximum Length Clause for the Add Attribute Command

Attributes defined as type String can also contain a maximum length clause. This clauses allows you to define the maximum number of characters the attribute’s value can contain.

This clause is very useful in enabling greater interoperability with other systems where attribute length is also constrained. After the maximum length is defined, an error will occur if you attempt to create or modify an attribute with a greater number of characters.

If the maximum length definition of an attribute is 0, existing attributes can have values of unlimited length. If the maximum length of a string is modified for an attribute, and the attribute value is greater than or equal to 1020 bytes and violate the maximum length, the modifying of maximum length will produce an error with the offending value’s object ids. Otherwise, modifying an attribute’s maximum length allows existing values to be retained.

By default maximum length is defined as zero (0) where zero means an unlimited number of characters. The number you define for the maximum length does not take into account the different character encoding types (UTF8, UTF16, and so on).

SQL Server restricts the size of the index to 900 bytes. For example, if you try to create two string attributes with length 255, since they are nvarchar columns, the size of the index for string attributes is calculated as 255*2 (for Unicode), which would go over the limit. You can use the maxlength clause with the Add Attribute command to restrict the size so that indexing is right.