SQL Error : String or binary data would be truncated

While working on an application I found an error 'String or binary data would be truncated.After finding the solution I thought to publish it.
Whenever you see the message : 
string or binary data would be truncated 
That means the field is NOT big enough to hold my data. Check the table structure you will find that the length of one or more fields is not big enough to hold the data you trying to insert.
For example : As the column 'FIRSTNAME VARCHAR(5)' is able to hold 5 characters and you are trying to put characters greater than  5 in it then you will get this error.Increase the size of the field or decrease the value while inserting.

Comments

Popular posts from this blog

Enable HTTP Transport Security (HSTS) in IIS 7

When to use Truncate and Delete Command in SQL

Extension Class in C#