Question : indexing a varchar field

I still have a lot to learn about indexing, but, my particular question is about an index on a varchar column. This column was originally set up with a length of 255, although there are not any entries over 10 characters.
Will it actually make a difference if I index the way it is, versus changing the lenght to 10 then indexing? (sql server 2005)
thanks
alan

Answer : indexing a varchar field

it depends what you store in your varchar(8000) or varchar(1)

you can store the same value in both-

---
if you do not plan to keep 255 chars in varchar(255) -just max to 10 chars

then there is no reason to have it so big ..

otherwise. it is varchar (not char) - index size will be based on actual data there..

--

after such changes (from 255->10) - you need to recreate index (just DBCC DBREINDEX)

http://msdn.microsoft.com/en-us/library/ms181671.aspx

Random Solutions  
 
programming4us programming4us