查一下变量@Int_Temp3是否为NULL值,NULL+数值后还是NULL

解决方案 »

  1.   

    在这三个语句前面加上
    Select @Int_Temp3=0
    就可以看到@Char_S这个语句了,
    可是提示:第 1 行: '=' 附近有语法错误。
    不知道怎么回事,而且,那个@Char_S语句使用Exec(@Char_S)也不能执行
      

  2.   

    你是要取出表内符合条件的记录?
    用此方法:
    declare @Int_Temp3 int --
    declare @char_ino varchar(20)
    declare @Char_S nvarchar(1000)set @char_s='select @Int=count(*) from '+@Char_lno
    exec sp_executesql @char_s,N'@Int int output',@int_temp3 output
    select @int_temp3
      

  3.   

    select @int_temp3
    这句话是干什么用的?
    这样运行就能得到@Int_Temp3吗?
      

  4.   

    exec sp_executesql @char_s,N'@Int int output',@int_temp3 output
    运行系统存储过程,并传出变量即count(*)的结果
    select @int_temp3 帮你调试用,可不要
      

  5.   

    set @Char_SQL='select @Int=count(*) from '+@Char_lno+' where Lab_Date='''+convert(varchar(20),@Time_spare)+''---Lab_Plan=''
    exec sp_executesql @Char_s,N'@int int output',@Int_Temp2 output
    exec(@Char_SQL)
    print @Int_Temp2我实际的运行程序是这样的,可是@Int_Temp2没有显示结果啊
      

  6.   

    set @Char_S='select @Int=count(*) from '+@Char_lno+' where Lab_Date='''+convert(varchar(20),@Time_spare)+''
    exec sp_executesql @Char_S,N'@int int output',@Int_Temp2 output
    print @Int_Temp2刚才那个有问题,这个才是真的
      

  7.   

    那又是@Char_SQL为空字符串
    检查@Char_lno @Time_spare是否为NULL
      

  8.   

    convert(varchar(20),@Time_spare) 也成问题,要具体看一下convert使用法,你要的是那种时间值
      

  9.   

    如果只要日期:
    set @Char_S='select @Int=count(*) from '+@Char_lno+' where convert(varchar(10),Lab_Date,120)='''+convert(varchar(10),@Time_spare,120)+''''--要多两个''