dc

dc

  • NA
  • 663
  • 0

C# web using linq

Aug 4 2012 5:07 PM
In a C# 2010 web application that uses linq to sql datacontext object that connects to a sql server 2008 r2 database,  I need to do a maintenance change  to modify the size of a notes field from varchar(500) to varchar(900).

I am getting the error message, "changing the data type of column 'field2' on table 'test1' from 'varchar(500)' to 'varchar (900)' causes the following indexes to exceed the maximum index size of 900 bytes: index2 when change the column size using sql server management studio 2008 r2.

I am assuming that the datacontext object added this notes field to the index? If I am correct or not, can you tell me why a data field of this size would be used as a foreign key by the data context object.

I am trying to determine what my options are to fix this problem. The following is what I noted so far:

1. I saw the table I am referring to is a clustered index and I do not want to change the index for this reason. Note there are several foreign keys in the table I am referring to, however the primary key to this table is an 'int'. The only option I can see is to increase the size of the field to varchar(886) instead of varchar(900).

2. Could I change the field to a text size? This way the field can be the size the user may need.  Can  you tell me if this is a good option or not any why?

3. Is there a way I could change the data context object so this field is not a foreign key to another table? If so, how would I accomplish this goal?

4. Are there any other options I would have?



Answers (3)