Previous Topic

Book Contents

Book Index

Next Topic

MS SQL - Index Length Limitations

The SQL Server has a limit of 900 bytes on the total length of columns used in index.

Example:

CREATE UNIQUE INDEX I_USAGETYPE ON dbo.AMA_USAGETYPE (

USAGE_TYPE -- varchar(254),

USAGE_TYPE_DESC -- varchar(254),

CLIENT -- char(6)

)

If total index length is exceeded:

  • The resulting index is created with a warning.
  • Inserting or updating data whose total length in bytes exceeds the limit will cause an SQL exception

There are several ways of dealing with the problem:

  • Keep the index with a warning.

    This option can be used only if the current and also the expected data falls within the limit. This must be verified on the data actually present in the database.

  • Shorten the length of one or more char/varchar columns.

    This option is similar to the previous one. It expects data not to exceed the requirement, plus it additionally prevents too long data from being inserted at all.

  • Exclude one or more char/varchar columns in the index from conversion to Unicode.

    If some of the indexed columns contain data which never use special characters (e.g. attributes names, statuses…), then these columns can be excluded from conversion to Unicode.

    To use this option, set the column’s 'UnicodeDisabled' extended property in the Object Type Customizer.

  • Do not recreate the index in the process of conversion to Unicode.

    This option means that the index dropped during the database conversion is not re-created afterwards. Beware that this may negatively affect performance. The option is applicable only to non-unique indexes.

Note: Problematic indexes in the standard Valuemation database are solved by setting the UnicodeDisabled property where appropriate.

See Also

Databases Without Database Level Support

MS SQL - Unicode Implementation Scenarios