declare @Result varchar(200)
set @Result=''
select
    case 
    when route_spot is not null then @Result=@Result+route_spot+',' end
    end
from 
 tlinerouteinfo 
where 
 route_lineid=10select @Result————————————————————
消息 102,级别 15,状态 1,第 17 行
'=' 附近有语法错误。

解决方案 »

  1.   

    declare @Result varchar(200)
    set @Result=''
    select
       @Result=@Result+route_spot+','   from  tlinerouteinfo  
    where  
     route_lineid=10 and route_spot is not null select @Result
      

  2.   


    少 ELSE
    select case when  then else end --语法格式
      

  3.   

    case when 语法不是这样用的
    select  @Result= @Result+
      case  
      when route_spot is not null then route_spot+','
     else '' 
      end
    from  或者用一楼的
      

  4.   

    非常感谢 TravyLee及Beirut ,看到TravyLee的回复时,我发现我真笨,呵呵,的确是可以在WHERE中判断的,脑子没转过弯来。当然通过beirut的回复让我了解了正确的使用语法,呵呵。感觉两位。也感谢zhaowenzhong,虽然你的回复测试了但还是有错误。呵呵。结贴