当前位置: 代码迷 >> Sql Server >> 小弟我有个存储过程,找不出来有关问题,向高手请问
  详细解决方案

小弟我有个存储过程,找不出来有关问题,向高手请问

热度:196   发布时间:2016-04-27 19:35:04.0
我有个存储过程,找不出来问题,向高手请教!
CREATE PROCEDURE [dbo].[REPORT_FEE_TEST]
-- @REPORTTYPE VARCHAR(20),
@PLATFORM VARCHAR(20),
@SETTLEMENTTIMEBEGIN VARCHAR(20),
@SETTLEMENTTIMEEND VARCHAR(20),
@PAYTIMEBEGIN VARCHAR(20),
@PAYTIMEEND VARCHAR(20)
 AS
DECLARE @SQLSTR VARCHAR(8000)
DECLARE @SQLFIELD1 VARCHAR(8000)
DECLARE @SQLFIELD2 VARCHAR(8000)
DECLARE @SQLFIELD3 VARCHAR(8000)
DECLARE @SQLFIELD4 VARCHAR(8000)
DECLARE @SQLCode VARCHAR(400)
DECLARE @SQLNAME VARCHAR(400)

DECLARE cur_FeeItem Cursor FOR
SELECT
CODE,NAME
FROM
CodeTable 
WHERE 
CodeType='FeeItem' Order By CodeId

OPEN cur_FeeItem
FETCH NEXT FROM cursor_FeeItem INTO @SQLCode,@SQLName
WHILE @@FETCH_STATUS = 0

BEGIN

SET @[email protected] +',0.00 AS [email protected]
SET @[email protected]+',[email protected]+'.ComFee [email protected]
SET @[email protected]+',orderfee AS [email protected]
SET @[email protected]+' AND a.SapOrd = [email protected]+'.SapOrd and [email protected]+'.feeitem [email protected]

FETCH NEXT FROM cursor_FeeItem INTO @SQLCode,@SQLName
END
CLOSE cursor_FeeItem
DEALLOCATE cursor_FeeItem

SET @SQLSTR='
select a.DeatLike,b.ComFee AS MainFee [email protected] +'
from tmsorder a,orderfee b,
(select 
tranno 
from 
trannofee 
where 
FeeSMStatus = '''0''' 
group by tranno) c,
SettlementDetail d,
Settlement e
where 
a.SapOrd = b.SapOrd
and a.tranno =c.tranno
and a.tranno = d.tranno
and d.SettlementNo =e.SettlementNo
and b.feeitem = '''MainFee'''
and e.SettlementTime >= @SettlementTimeBegin 
  and e.SettlementTime <= [email protected]''' 
and b.paytime >= @PAYTIMEBEGIN and b.paytime <= @PAYTIMEEND

union

select 
a.DeatLike,0.00 AS MainFee,[email protected]+ ' 
from 
tmsorder a,
(select 
invoice 
from 
invoicefee 
where 
FeeSMStatus = '''0''' 
group by invoice ) as c
SettlementDetail d, Settlement e [email protected]+ '

where 
a.invoice =c.invoice
and a.tranno = d.tranno
and d.SettlementNo=e.SettlementNo [email protected]+ '
and e.SettlementTime >= [email protected]'''and e.SettlementTime <= [email protected]''' 
and b.paytime >= [email protected]''' and b.paytime <= [email protected]''''


------解决方案--------------------
' ' 'MainFee ' ' ' 

字符串的'=''
  相关解决方案