1

I keep getting the following error when trying to update my database in Visual Studio 2013. Has anyone ever experienced a similar problem or know how to resolve this issue?

Thanks!

Creating [dbo].[Email]...

Msg 1975, Level 16, State 1, Line 58 Index 'PK__Email__3214EC07F586A15A' row length exceeds the maximum permissible length of '8060' bytes. Msg 1750, Level 16, State 0, Line 58 Could not create constraint. See previous errors. ** An error was encountered during execution of batch. Exiting.

  • Can you show the structure of your EMail table? And why you need a PrimaryKey with more than 8060 bytes? – Steve Apr 09 '16 at 10:02
  • Hello thank you for your reply, please see the link to view my current table structure. The table is going to hold email data imported from a .CSV file. http://i328.photobucket.com/albums/l354/Diarmuid_Bogner/database_structure_zpspyetveq0.png – Diarmuid Bogner Apr 09 '16 at 10:42
  • 2
    I suggest to change the Body field to ntext then because there is no clear limit to the lenght of an email text and also change the nchar fields to nvarchar to better handle the variability of the text length of these fields – Steve Apr 09 '16 at 10:59

2 Answers2

0

After looking at table you've created I think it will help pointing out that since you can't determine the size of the body of the email it's wrong setting a size for it. I will advise using something like

Varchar(max)

Which will help in avoiding errors about length like the one you're having

This should help What is the difference between char, nchar, varchar, and nvarchar in SQL Server?

Community
  • 1
  • 1
jamiedanq
  • 967
  • 7
  • 12
0

@Steve after changing the required field types I was able to successfully Update the table thank you very much!

Change the Body field to ntext then because there is no clear limit to the lenght of an email text and also change the nchar fields to nvarchar to better handle the variability of the text length of these fields.