1.不是占用资源多的问题,而是速度慢的问题,当然,速度慢,要长期占用资源,也算是占用资源多吧.2.@temp_pjxfjd 的值是NULL

解决方案 »

  1.   

    1、游标占用资源比较大2、Declare @temp_pjxfjd float 
    SELECT @temp_pjxfjd = case when JX_Score.Credit=1 then 0 when  JX_Score.Credit=2 then 1 when  (JX_Score.Credit<>1 and JX_Score.Credit<>2) then 3 end 
    from JX_score where .....如果根据条件一条记录都没有。那@temp_pjxfjd=3
      

  2.   

    --测试第二个问题--测试数据
    create table 表(aa float)
    insert 表 select 1
    union all select 2
    union all select 3
    go--查询
    Declare @temp_pjxfjd float 
    SELECT @temp_pjxfjd = case when aa=1 then 0 when  aa=2 then 1 when  (aa<>1 and aa<>2) then 3 end 
    from 表 where aa>100select @temp_pjxfjd
    go--删除测试环境
    drop table 表/*--测试结果(所影响的行数为 3 行)                                                      
    ----------------------------------------------------- 
    NULL(所影响的行数为 1 行)--*/
      

  3.   

    @temp_pjxfjd是null??
    但结果好像不是这样的,我判断了
    if @temp_pjxfjd=null 
       print '1'
    else 
       print '2'
    结果是2 
    请指教
      

  4.   

    arrow_gx(8088的脑袋) 
    呵呵,问题不是这样的。。
      

  5.   

    if @temp_pjxfjd is null 
       print '1'
    else 
       print '2'
      

  6.   

    联机帮助:
    如果省略else参数并且比较运算取值不为 TRUE,CASE 将返回 NULL 值。
      

  7.   

    --or
    set ansi_nulls off
    if @temp_pjxfjd = null 
       print '1'
    else 
       print '2'
    set ansi_nulls on
      

  8.   

    --你自己写错了,判断null不是这样判断的,应该这样判断if @temp_pjxfjd is null 
       print '1'
    else 
       print '2'