sql存储过程问题(100)

  • 主题发起人 cncangel
  • 开始时间
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;这句话是什么意思!
 
S

sunnyfairy

Unregistered / Unconfirmed
GUEST, unregistred user!
这不是你写的吧.SQL中%是模糊查询怎么能这么用.exec @i=rp_427413 %D1%,%D2% select @i;这句话是什么意思! 本意估计是执行一个proc 然后将该存储过程返回值传给变量i, 然后取得i值.你找本语法书看看吧.都是基础内容.
 
H

haidy

Unregistered / Unconfirmed
GUEST, unregistred user!
你这是什么类型的数据库啊?数据库里面有没有rp_427413这样的对象?rp_427413是不是自定义函数之类的?
 
C

cncangel

Unregistered / Unconfirmed
GUEST, unregistred user!
是富基的自定意报表过程,因为运行报错,所以我想知道%D1%,%D2%是什么意思,百分号的模糊查询我知道,我不太理解为什么要用百分号来定意变量!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
573
import
I
I
回复
0
查看
718
import
I
I
回复
0
查看
577
import
I
顶部