String or binary data would be truncated

While inserting row in SQL Server, whenever you encounter such error then you need to re-verify whether or not you are exceeding any column value

for example in your sql table you have defined length of other_name as char(12)
create table users
(
code integer identity(1,1) primary key,
username varchar(32) not null unique,
other_number char(12) not null
)

and if your insert statement is as follows
insert into users (username,other_number) values('admin','1234567890123');

only then this error will come i.e String or binary data would be truncated

which means you are exceeding length check of column named other_name therefore reducing it will insert row successfully like below.

insert into users (username,other_number) values('admin','123456789012');

Comments

Popular posts from this blog

storing byte array as column value in datatable using c#

post form data and bind with model : using jquery ajax in mvc

Htc sensation XL mobile not working with windows 7 or above, along with Htc sync software