明明定义了字段strname是varchar(34)类型,但是插到数据库里的串不满34个,用len(strname)查得的结果还是34,不知道是为什么?

解决方案 »

  1.   

    会不会是客户端程序加上去的,是怎么插入的,用了存储过程没有??顺便给我的帖子作广告,在线等待
    http://community.csdn.net/Expert/topic/4618/4618652.xml?temp=.1497461
      

  2.   

    declare @tb table(strname varchar(34))
    insert @tb
    select '232' union all
    select '23werw2' union all
    select '23werwewewe2' select len(strname) from @tb结果:
    3
    7
    12
      

  3.   

    首先确认插入的有没有空格等难看到了字符。
    还有前台程序的是否把长度截断了,可用
    跟踪器profiler跟踪一下插入的语句。
      

  4.   

    试试len(rtrim(ltrim(strname))),我估计你写入的串有空格等不可见字符
      

  5.   

    通过ODBC绑定的,会不会绑定时长度指定的不对呢
      

  6.   

    SET ANSI_PADDING OFF
    之后,重新建立表,向表中插入数据,再看一下结果