Sql-server – creating an index for varchar column greater than 900 bytes

indexsql serversql-server-2008

I have a var char column in SQL Server 2008 which is usually less than 100 bytes but in some cases can be huge up 5607 bytes. I need to index it, and I can't because the max index size in SQLServer is 900 bytes.

Is there any way in the world I can add any sort of an index to this column? For example, create an index on the first 900 bytes?

Thanks

Best Answer

If you need an index so seeks on the first n characters work well (where n <= 900 bytes), you can create a computed column of LEFT(column, n) and index that. If you want an index for exact matching, sorry, there isn't a way that I know of to do that unless you use a checksum or similar. Can you explain the actual business problem? What strings > 900 bytes do you feel would benefit from such an index, and why?