if len(ltrim(rtrim(@chrWhere)))>0
begin
set @a1=charindex('入库日期 >=',@chrwhere)+11
set @a2=charindex('入库日期 <=',@chrwhere)+11
-- set @a3=charindex('供应商 = ',@chrwhere)+9
if @a1>11 set @startdate=substring(@chrwhere,@a1,charindex('''',@chrwhere,@a1)-@a1)
if @a2>11 set @stopdate=substring(@chrwhere,@a2,charindex('''',@chrwhere,@a2)-@a2)
-- if @a3>9 set @b=substring(@chrwhere,@a3,200)
end
set @b=left(@b,len(@b)-3)
-- set @b=right(@b,len(@b)-2)
print charindex('''',@chrwhere,@a3)
有劳高手解释以上代码。谢
begin
set @a1=charindex('入库日期 >=',@chrwhere)+11
set @a2=charindex('入库日期 <=',@chrwhere)+11
-- set @a3=charindex('供应商 = ',@chrwhere)+9
if @a1>11 set @startdate=substring(@chrwhere,@a1,charindex('''',@chrwhere,@a1)-@a1)
if @a2>11 set @stopdate=substring(@chrwhere,@a2,charindex('''',@chrwhere,@a2)-@a2)
-- if @a3>9 set @b=substring(@chrwhere,@a3,200)
end
set @b=left(@b,len(@b)-3)
-- set @b=right(@b,len(@b)-2)
print charindex('''',@chrwhere,@a3)
有劳高手解释以上代码。谢
然后把@B去掉后三位,然后打印@chrwhere从@a3里存的数字开始的第一个单引号的位置
begin
set @a1=charindex('入库日期 >=',@chrwhere)+11 --查出'入库日期 >='在@chrwhere中的位置+11
set @a2=charindex('入库日期 <=',@chrwhere)+11 --查出'入库日期 <='在@chrwhere中的位置+11
if @a1>11 --当@chrwhere包含'入库日期 >='时
set @startdate=substring(@chrwhere,@a1,charindex('''',@chrwhere,@a1)-@a1)--截取从入库日期 >=到'之间的字符串放到@startdate
if @a2>11 --当@chrwhere包含'入库日期 <='时
set @stopdate=substring(@chrwhere,@a2,charindex('''',@chrwhere,@a2)-@a2)--截取从入库日期 <=到'之间的字符串放到@stopdate
end
set @b=left(@b,len(@b)-3) --去掉@b的后3位(这个@b不知道是从哪冒出来的)
print charindex('''',@chrwhere,@a3) --在消息中显示从第@a3位起‘的位置(这个@a3也不知道是从哪冒出来的)
begin
set @a1=charindex('入库日期 >=',@chrwhere)+11 --'入库日期 >='在@chrwhere中的位置+11
set @a2=charindex('入库日期 <=',@chrwhere)+11 --'入库日期 <='在@chrwhere中的位置+11-- set @a3=charindex('供应商 = ',@chrwhere)+9
if @a1>11 set @startdate=substring(@chrwhere,@a1,charindex('''',@chrwhere,@a1)-@a1)--取得起始日期,入库日期 >=后面的日期
if @a2>11 set @stopdate=substring(@chrwhere,@a2,charindex('''',@chrwhere,@a2)-@a2)--取得终止日期,入库日期 <=后面的日期
-- if @a3>9 set @b=substring(@chrwhere,@a3,200)
end
set @b=left(@b,len(@b)-3) --去除@b的后三位
-- set @b=right(@b,len(@b)-2)
print charindex('''',@chrwhere,@a3)