How to resolve 900 key length limit index on the column which have datatype varchar(4096) in SQL Server 2005?

白昼怎懂夜的黑 提交于 2019-12-04 14:35:27

You can't - as the error message already clearly states, any index entry cannot be more than 900 bytes long.

You cannot index a varchar(4096) field - period. No way around that - it's a hard SQL Server limit - no way to configure it, change it, make it bigger. See Books Online - Maximum Size of Index Keys for confirmation.

You need to either limit your "value" column to less than 900 bytes, or find another way to store that data - or just not include it in the index. If you only want your "value" field in the index to have a covering index (to be able to satisfy queries from the index entry), you could move the field to be an included column in the index - those don't fall under the 900 byte limit.

CREATE NONCLUSTERED INDEX idx_ncl_2 
  ON BFPRODATTRASSOCIATION(attributeid) 
  INCLUDE (productid, value)

That index should work.

You could create and index on a computed column that is the hash of the string. See Hash functions in T-SQL and Intelligent Database Design Using Hash Keys for some ideas and limitations.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!