select
FRealAmt=b.FTaxSubmitAmt,
FRealAmtFor=b.FTaxSubmitAmtFor,
FRealDeprID = a.FDeptID,
FRealEmpID= a.FProposerID ,
FRealExpID= b.FExpID,
FRealItemClassID= b.FItemClassID,
FRealItemID=b.FItemID,
FProjectID = 1000,
a.FCurrencyID as FCurrencyID,
c.Fname as department,
d.Fname as employee,
REVERSE(LEFT(REVERSE(e.FFullName),CHARINDEX('_',Reverse(e.FFullName))-1)) as ItemName,
e.Fname as expensive,
FCheckDate,
FDate,
a.FCheckStatus as FCheckStatus,
b.Fnote as fnote,
e.FitemClassID as FitemClassID,
e.Fnumber as Fnumber
from t_BM_ExpReimbursement a
Inner Join t_BM_ExpReimbursementEntry b On a.FID=b.FID
Inner Join t_Currency cur on cur.FCurrencyID =a.FCurrencyID
Inner Join t_item c on c.FItemID=a.FDeptID
Inner Join t_item d on d.FItemID=a.FProposerID
Inner Join t_item e on e.FItemID=b.FExpID
注示掉 REVERSE(LEFT(REVERSE(e.FFullName),CHARINDEX('_',Reverse(e.FFullName))-1)) as ItemName 后 改为 Select ..... Inner Join t_item e on e.FItemID=b.FExpID and e.Flevel < 2 执行没有数据
改为 Select ..... Inner Join t_item e on e.FItemID=b.FExpID and CHARINDEX('_',Reverse(e.FFullName))=0 执行没有数据
把刚才注示掉的 REVERSE(LEFT(REVERSE(e.FFullName),CHARINDEX('_',Reverse(e.FFullName))-1)) as ItemName 恢复改为 Select ..... Inner Join t_item e on e.FItemID=b.FExpID and e.Flevel > 1 可以正常执行
不清楚为什么没有 and e.Flevel > 1 就报错
------解决方案-------------------- 不清楚为什么没有 and e.Flevel > 1 就报错
说明符合 e.Flevel > 1 的数据都可以CHARINDEX('_',FFullName)
如果没有这个e.Flevel > 1的条件,数据中FFullName可能不存在'_',就会报错。
------解决方案--------------------
那应该是数据的原因,就是e.Flevel<=1的条件中有数据不正确,或不满足一下查询要求,导致查询报错
------解决方案-------------------- Select ..... Inner Join t_item e on e.FItemID=b.FExpID and CHARINDEX('_',Reverse(e.FFullName))=1
有没有数据。
------解决方案--------------------
------解决方案-------------------- 加个条件看看
where CHARINDEX('_',Reverse(e.FFullName)) > 1
------解决方案-------------------- 传递到 SUBSTRING 函数的长度参数无效?