请教一个SQL存储过程的问题
例:CREATE proc cpoutquery
@dh varchar(50),@dhs int,@bh varchar(50),@bhs int,@ssdw varchar(50),@ssdws int,@qw varchar(50),@qws int,@cw varchar(50),@cws int,@kh varchar(50),@khs int,
@sh varchar(50),@shs int,@mq varchar(50),@mqs int,@rq varchar(200),@mc varchar(100)
as
set @rq=" and s_outczrq>= '2009-08-05' and s_outczrq<= '2009-08-05'"
select s_outdh,s_fty_id,s_mqty,s_part_no,s_desc,s_out_qty,s_outczrq,s_to_id,s_qw,s_to1_id,s_number,s_po_no,s_id
from s_stdn with (index=s_stdn_out)
where substring(s_outdh,1,@dhs) = @dh and substring(s_part_no,1,@bhs)=@bh and substring(s_to1_id,1,@ssdws)=@ssdw
and substring(s_qw,1,@qws)=@qw and substring(s_to_id,1,@cws)=@cw and substring(s_fty_id,1,@khs)=@kh and substring(s_number,1,@shs)=@sh
and substring(s_mqty,1,@mqs)=@mq and s_out_qty<>0 + @rq
GO
运行后报错:
将 varchar 值 ' and s_outczrq>= '2009-08-05' and s_outczrq<= '2009-08-05'' 转换为数据类型为 int 的列时发生语法错误。
请问怎样解决!
其实@rq是程序中的变量
在这里set @rq=" and s_outczrq>= '2009-08-05' and s_outczrq<= '2009-08-05'"只是举一个值 @rq等于=" and s_outczrq>= '2009-08-05' and s_outczrq<= '2009-08-05'"的例子.