Results 1 to 5 of 5

Thread: "String or binary data would be truncated" when data is OK

  1. #1
    Join Date
    Feb 2006
    Posts
    3

    "String or binary data would be truncated" when data is OK

    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.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Since column length in source tables are 128 characters, name will be truncated if it has more than 18 characters.

  3. #3
    Join Date
    Feb 2006
    Posts
    3
    Yes, I realize that. But the data that is actually being selected does not exceed a length of 18.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    But it still gives you warning.

  5. #5
    Join Date
    Feb 2006
    Posts
    3
    Yes, I get an error in SqlServer 2005, but no error in SqlServer 2000.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •