日期:2014-05-18  浏览次数:20536 次

(50分求解)存储过程中定义了varchar(1000),为什么调试时字符串被截断?
存储过程定义了以下变量:
declare   @sql   varchar(1000)

set   @sql= 'insert   tmp   select   *   from   (select     distinct   i.*   from   zd   z,im   i   where   (charindex(i.from,z. '+@IM+ ')> 0   or   charindex(i.to,z. '+@IM+ ')> 0)   and   len(z. '+@IM+ ')> '+@length+ '   and   i.imtype= '+@IMType+ ')   i1   where   not   exists(select   *   from   imtmp   i   where   i.ac=i1.ac   and   i.ime=i1.time   and   isnull(i.cont, ' ' ' ' ' ')=isnull(i1.cont, ' ' ' ' ' ')   and   i.dest=i1.dest   and   i.from=i1.from   and   i.type=i1.type   and   i.src=i1.src   and   i.to=i1.to) '

以上这段insert代码在分析器中执行一点问题都没有,但将其变为存储过程就发现字符串被截断了。调试时发现@sql只有456个字符,后面的字符都没了,怎么回事?

------解决方案--------------------
isnull(i.cont, ' ' ' ' ' ')=isnull(i1.cont, ' ' ' ' ' ')
这里有问题,应该是isnull(i.cont, ' ' ' ')=isnull(i1.cont, ' ' ' ')