有条件@layer=0,那么第一次循环时left(@ptypeid,5*@layer)就会出错,
呵呵~~应该是这里吧,还有函数中不有能用print.

解决方案 »

  1.   

    while @layer=0这里不对,这们你的循环一次也不会执行。按你的要求应为
    while @layer>=0还有left(@ptypeid,5*@layer)
    改为:left(@ptypeid,5*@layer+1)
      

  2.   

    print @layer这一句不能放在函数中啊,我上面也说了。
      

  3.   

    print @layer 已经去除了
      

  4.   

    http://expert.csdn.net/Expert/topic/1448/1448277.xml?temp=.2130243再次调试,print @layer 已经去除了错误提示依旧
      

  5.   

    select @allpath=(select top 1 dbo.ptype.fullname where dbo.ptype.typeid =left(@ptypeid,5*@layer) from dbo.ptype order by dbo.ptype.typeid)+'\'+@allpath这个语句From前面有Where,这肯定是不对的,是笔误吗?
    可能应为:select @allpath=(select top 1 dbo.ptype.fullname  from dbo.ptype 
    where dbo.ptype.typeid =left(@ptypeid,5*@layer)
    order by dbo.ptype.typeid)+'\'+@allpath
      

  6.   

    select @allpath=(select top 1  dbo.ptype.fullname  from dbo.ptype where dbo.ptype.typeid =left(@ptypeid,5*@layer) order by dbo.ptype.typeid)+'\'+@allpath
    是不是这里有问题?怎么where 放前面了?