We’re changing the data type of one of the columns in our SQL Server 2008 database from varchar(900) to nvarchar(900). This will cause the data size of the column to change from 900 bytes to 1800 bytes.
This column is included in an index and when we make the change to the index we get the warning
*Warning! The maximum key length is 900 bytes. The index ‘INX_SomeTable’ has maximum length of 1800 bytes. For some combination of large values, the insert/update operation will fail.*
We’re planning to address this by reducing the field size from nvarchar(900) to nvarchar(450). I’d like to make sure that there are no columns feeding into the field that exceed 450 characters.
How can I query the system tables or DMVs to find all character fields (varchar or nvarchar) that exceed a certain size?
1 Answer