变换一下方式,就行了select @ldc_sxdj_01=(case df_code when '02' then fdj
                                  when '03' then ...
                    end),
      @ldc_sxdj_02=(case   ....  when   then  end).....

解决方案 »

  1.   

    土办法:select 
       @ldc_sxdj_01=fdj,@ldc_sxdj_02=gdj,@ldc_sxdj_03=pdj 
    from #t_kh_yd_code2
    where sn_id=@i and df_code = '02'
    union all
    select 
       @ldc_csdj_01=fdj,@ldc_csdj_02=gdj,@ldc_csdj_03=pdj
    from #t_kh_yd_code2
    where sn_id=@i and df_code = '03'
    union all
    select 
       @ldc_nwdj_01=fdj,@ldc_nwdj_02=gdj,@ldc_nwdj_03=pdj
    from #t_kh_yd_code2
    where sn_id=@i and df_code = '04'
    union all
    select 
       @ldc_wgdj_01=fdj,@ldc_wgdj_02=gdj,@ldc_wgdj_03=pdj
    from #t_kh_yd_code2
    where sn_id=@i and df_code = '05'
      

  2.   

    to  lsxaa(小李铅笔刀) :呵呵,我有15个变量呢,这样起不是很长啊,hehe ~~~~~~~