Select @MaxTime = max(DataTime) from Test where WMeterID=@WMeter_ID
这里我如果select不到行.也就是没有数据
为什么我用
if(@MaxTime = '')或者if(@MaxTime = null)
都无法判断呢?
只有@MaxTime有确切值的时候才能判断.晕了,我又不想用count(*)来判断,貌似浪费操作

解决方案 »

  1.   

    if(@MaxTime = null) 
    ==
    if(@MaxTime is null) 
      

  2.   

    你可以这样判断更好if exists(Select 1 from Test where WMeterID=@WMeter_ID )
      

  3.   

    if(isnull(@MaxTime,'') = '')
    --or
    if(@MaxTime is null) 
      

  4.   

    isnull 
      

  5.   

    用if(isnull(@MaxTime,'') = '')
      

  6.   


    declare @MaxTime = '' datetime
    然后再判断
      

  7.   


    if(isnull(@MaxTime,'') = '')='' 或是 null 都可以判断了。也来JF点。。