C
cncangel
Unregistered / Unconfirmed
GUEST, unregistred user!
create table #427413( SortID int default 0 null, shopid char(4) null, goodsid int null, barcodeid char(13) null, goodsName char(64) null, spec char(16) null, UnitName char(8) null, deptID int null, deptName char(16) null, cost dec(16,4) default 0 null, Price dec(16,4) default 0 null, DMS dec(16,4) default 0.05 null, SaleQty dec(16,4) default 0 null, SaleValue dec(16,4) default 0 null, SaleCost dec(16,4) default 0 null, GPValue dec(16,4) default 0 null, GPRate dec(16,2) default 0 null, Venderid int null, VenderName char(64) null, PMFlag int null, CloseQty dec(16,4) default 0 null, CloseValue dec(16,4) default 0 null, discvalue dec(12,4) default 0 null )declare @i int exec @i=rp_427413 %D1%,%D2% select @i;update #427413 set venderName=v.name from #427413 a,vender v where a.venderid=v.venderid;update #427413 set DeptName=d.Name from #427413 a,SGROUP d where a.deptid/10000=d.id;select * into #427413out from #427413 where 1=1 %K% %CB% order by %T% %P%;declare @iCount intdeclare @sqlstring char(255)declare @str char(10)declare @sCount char(10)select @iCount=count(*) from #427413outselect @str=%X%if charindex('%',@str)>0 begin select @sCount=substring(@str,1,charindex('%',@str)-1); select @icount=@icount*cast(@sCount as int)/100 endelse select @icount=cast(@str as int)select * into #temp_427413 from #427413out where 1=0;select shopid,goodsid,barcodeid,goodsname,spec,unitname, deptid/10000 deptid,deptname,cast('0' as char(16)) brand, cost, price,sum(saleqty) saleqty,sum(salevalue) salevalue, sum(salecost) salecost,sum(gpvalue) gpvalue,sum(isNull(GPValue,0))*100/sum((case SaleValue when 0 then 1 else SaleValue end)) gprate,sum(closeqty) closeqty, sum(closevalue) closevalue,sum(discvalue) discvalue into #427413out1from #427413out where 1=1 and shopid not in('s00s','s00a') %shopid%group by shopid,goodsid,barcodeid,goodsname,spec,unitname,cost,price, deptid/10000,deptnameorder by sum(%T%) %P% ;select * into #427413out2 from #427413out1 where 1=0;select @sqlstring='insert into #427413out2 select top ' +cast(@icount as char(10)) + ' * from #427413out1'execute (@sqlstring);GOupdate #427413out2 set cost=salecost/saleqty,price=salevalue/saleqty from #427413out2;update #427413out2 set brand=c.name from #427413out2 a,goods b,brand c where a.goodsid=b.goodsid and b.brandid=c.id;------------------------报错如下-----------------------------------------------服务器: 消息 170,级别 15,状态 1,行 27第 27 行: '%' 附近有语法错误。服务器: 消息 170,级别 15,状态 1,行 33第 33 行: 'CB' 附近有语法错误。服务器: 消息 170,级别 15,状态 1,行 40第 40 行: 'X' 附近有语法错误。服务器: 消息 170,级别 15,状态 1,行 53第 53 行: '%' 附近有语法错误。---------------------------对应行代码如下---------------------------------第 27 行: '%' 附近有语法错误。[red]declare @i int exec @i=rp_427413 %D1%,%D2% select @i;[/red]第 33 行: 'CB' 附近有语法错误。[red]select * into #427413out from #427413 where 1=1 %K% %CB% order by %T% %P%;[/red]第 40 行: 'X' 附近有语法错误。[red]select @str=%X%[/red]第 53 行: '%' 附近有语法错误。[red]from #427413out where 1=1 and shopid not in('s00s','s00a') %shopid%[/red]--------------------------------------------------------------------------------请问以上问题如何处理?exec @i=rp_427413 %D1%,%D2% select @i;这句话是什么意思!