你是要取出表内符合条件的记录? 用此方法: 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
select @int_temp3 这句话是干什么用的? 这样运行就能得到@Int_Temp3吗?
exec sp_executesql @char_s,N'@Int int output',@int_temp3 output 运行系统存储过程,并传出变量即count(*)的结果 select @int_temp3 帮你调试用,可不要
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没有显示结果啊
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刚才那个有问题,这个才是真的
如果只要日期: set @Char_S='select @Int=count(*) from '+@Char_lno+' where convert(varchar(10),Lab_Date,120)='''+convert(varchar(10),@Time_spare,120)+''''--要多两个''
Select @Int_Temp3=0
就可以看到@Char_S这个语句了,
可是提示:第 1 行: '=' 附近有语法错误。
不知道怎么回事,而且,那个@Char_S语句使用Exec(@Char_S)也不能执行
用此方法:
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
这句话是干什么用的?
这样运行就能得到@Int_Temp3吗?
运行系统存储过程,并传出变量即count(*)的结果
select @int_temp3 帮你调试用,可不要
exec sp_executesql @Char_s,N'@int int output',@Int_Temp2 output
exec(@Char_SQL)
print @Int_Temp2我实际的运行程序是这样的,可是@Int_Temp2没有显示结果啊
exec sp_executesql @Char_S,N'@int int output',@Int_Temp2 output
print @Int_Temp2刚才那个有问题,这个才是真的
检查@Char_lno @Time_spare是否为NULL
set @Char_S='select @Int=count(*) from '+@Char_lno+' where convert(varchar(10),Lab_Date,120)='''+convert(varchar(10),@Time_spare,120)+''''--要多两个''