# Database Discussions > Microsoft SQL Server 2005 >  "String or binary data would be truncated" when data is OK

## karenc

When using AquaData or JDBC (inet tds driver), when doing an insert, I get error "String or binary data would be truncated" when the data is actually OK.  There are no triggers, etc. that would confuse the situation.

The scenario is as follows:

Create table:
   create table test3 (
   name varchar (18) ,
   tbname varchar (18) 
   )

Create and populate table:
   create table maxtable (
   tablename varchar (18) not null,
   [...]
   )

Try to insert into test3:
   insert into test3 (name, tbname)  
   select i.name, o.name
   from dbo.sysindexes i, sysobjects o, maxtable m
   where i.indid > 0 and i.indid < 255  
   and i.id = o.id  and i.indid = 1  
   and o.name = lower(m.tablename)  

And I get the error "String or binary data would be truncated."  The values being selected for i.name and o.name have maximum length of 18.  There are other rows in sysindexes and sysobjects with longer values, but they are not being selected.

The error does not occur with SQL Server Management Studio, and does not occur using SqlServer 2000.

----------


## rmiao

Since column length in source tables are 128 characters, name will be truncated if it has more than 18 characters.

----------


## karenc

Yes, I realize that.  But the data that is actually being selected does not exceed a length of 18.

----------


## rmiao

But it still gives you warning.

----------


## karenc

Yes, I get an error in SqlServer 2005, but no error in SqlServer 2000.

----------

