如何将存储过程的数据源拿出来

语句如下,怎样才能让存储过程的数据源在报表里显示出来

USE [UFDATA_001_2021]

GO

/****** Object:  StoredProcedure [dbo].[xSDDYK]    Script Date: 2021-11-29 16:34:54 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER  PROCEDURE [dbo].[xSDDYK]

(

@cInvCode nvarchar(100)=null,

@cfree1 nvarchar(50)=null,

@cInvCCode nvarchar(50)=null,

@cidefine10 nvarchar(50)=null

)

as

begin 

--加索引

--select  sum(dls.fOutQuantity) as 总累计出库数量,dls.cinvcode as 存货编码a,isnull(dls.cfree1,'常规色') as 色号a,dls.cInvName as 存货名称1 into ##tmp1

--from DispatchLists dls

--left join SO_SODetails sds 

--on dls .cSoCode=sds.cSOCode

--left join SO_SOMain sm

--on sm.ID=sds.ID

--where dls.cordercode is not null and  sm.dclosedate is null --订单未关闭以及销售订单不为空

--group by dls.cinvcode , dls.cfree1,dls.cInvName --发货单表

----dls.fOutQuantity ,AutoID

----dls.fOutQuantity as 累计出库数量,AutoID 

--select   i.cinvname as 存货名称6,i.cInvCode as 存货编码b,case when (cs.cFree1='') then '常规色' else cs.cFree1 end as 色号b,i.cInvStd as 规格型号,sum(cs.iQuantity) as 总现存量 into ##tmp2

--from CurrentStock cs

--left join Inventory i   --/存货档案现存量表--数据正确

--on i.cInvCode=cs.cInvCode 

--where left(i.cInvCCode,2)=01 and cs.iQuantity>=0 

--group by i.cInvCode ,cs.cFree1,i.cInvStd ,i.cinvname

--select  sds.cInvCode as 存货编码,i.cInvName as 存货名称5 ,isnull(sds.cfree1,'常规色') as 色号c, sum(sds.iQuantity) as 销售订单数量, sum(sds.iFHQuantity )as 累计发货数量,sum(sds.iQuantity) - sum(sds.iFHQuantity ) as 销售订单未开单数量 into ##tmp3

--from SO_SOMain sm

--left join SO_SODetails sds

--on sm.id=sds.ID --销售订单主表/子表 数据正确

--left join Inventory i

--on sds.cInvCode =i.cInvCode

--where sm.dclosedate is null 

--group by sds.cInvCode,sds.cfree1 ,i.cInvName

--select ie.cInvCode,ie.cidefine10 into ##tmp4

--from Inventory_extradefine ie --存货档案扩展自定义

--select * ,##tmp3.销售订单数量-##tmp1.总累计出库数量 as 销售订单未发货单数量,##tmp2.总现存量-销售订单未开单数量 as 盈亏数,##tmp4.cidefine10 as 是否定制

--from ##tmp3

--left join ##tmp1 

--on ##tmp3.存货编码=##tmp1.存货编码a and ##tmp3.色号c=##tmp1.色号a

--left join ##tmp2

--on   ##tmp2.存货编码b=##tmp1.存货编码a and ##tmp2.色号b=##tmp1.色号a

--left join ##tmp4

--on ##tmp3.存货编码= ##tmp4.cInvCode

--where 

--(##tmp3.存货编码=@cInvCode or @cInvCode is null)

--and (##tmp3.色号c=@cfree1 or @cfree1 is null)

--drop table ##tmp1,##tmp2,##tmp3,##tmp4

select inc.cInvCCode,cInvCName,ta.cInvCode 存货编码,inv.cInvName 存货名称5,inv.cInvStd 规格型号,ta.cFree1 色号c,ta.iQuantity 销售订单数量,ta.iFHQuantity,

ISNULL(ta.iFHQuantity,0) 累计发货数量,ta.fQuantity 销售订单未开单数量,ISNULL(ct.iQuantity,0) 总现存量,(ISNULL(ct.iQuantity,0)-ta.fQuantity) 盈亏数,cidefine10

from (

select sd.cInvCode,sd.cFree1,sum(sd.iQuantity) iQuantity,sum(iFHQuantity) iFHQuantity,

sum(rd.iQuantity) fOutQuantity,sum(sd.iQuantity-ISNULL(rd.iQuantity,0)) fQuantity2,

sum(CASE WHEN ISNULL(sd.iFHQuantity,0)>sd.iQuantity then 0 else sd.iQuantity-ISNULL(sd.iFHQuantity,0) end) fQuantity

from so_somain sm with(nolock)

inner join so_sodetails sd with(nolock) on sm.ID=sd.ID

left join (select iSOsID,sum(iQuantity) iQuantity from DispatchLists group by iSOsID) rd on sd.iSOsID=rd.iSOsID

--left join (SELECT td.iSOsID,sum(rds.iQuantity) iQuantity

-- FROM rdrecords32 rds 

-- inner join rdrecord32 rd on rds.ID=rd.ID

-- left join DispatchLists td on td.iDLsID=rds.iDLsID

-- where ISNULL(rd.cHandler,'')!=''

-- group by td.iSOsID)rd on sd.iSOsID=rd.iSOsID

where ISNULL(sm.cVerifier,'')!='' and ISNULL(sm.cCloser,'')='' and ISNULL(sd.cSCloser,'')=''

group by sd.cInvCode,sd.cFree1--销售订单主表子表

)ta

left join (

select cInvCode,cFree1,

sum(iQuantity+fInQuantity-fOutQuantity+fTransInQuantity-fTransOutQuantity) iQuantity 

from currentstock with(nolock) 

group by cInvCode,cFree1--现存量表

) ct on ta.cInvCode=ct.cInvCode and ISNULL(ta.cFree1,'')=ISNULL(ct.cFree1,'')

left join inventory inv with(nolock) on ta.cInvCode=inv.cInvCode

left join Inventory_extradefine inf with(nolock) on ta.cInvCode=inf.cInvCode--是否定制

left join InventoryClass inc on left(inv.cInvCCode,2)=inc.cInvCCode--存货大类编码

where 1=1 -- and inc.cInvCCode='01' 

and (ta.cInvCode=@cInvCode or @cInvCode is null) 

and (ta.cFree1=@cfree1 or @cfree1 is null)

and (inc.cInvCCode=@cInvCCode or @cInvCCode is null)

and (inf.cidefine10=@cidefine10 or @cidefine10 is null)

order by ta.cInvCode

end;

FineReport zhangjinrui 发布于 2021-11-30 11:56
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
Z4u3z1Lv6专家互助
发布于2021-11-30 12:01(编辑于 2021-11-30 16:18)

image.png

这两行之间 加 set nocount on

image.png

  • zhangjinrui zhangjinrui(提问者) 还是不行
    2021-11-30 16:04 
  • Z4u3z1 Z4u3z1 回复 zhangjinrui(提问者) 加了 SET NOCOUNT ON 后直接用。报什么错?如果没数据就把 上图的 SQL 放到数据库管理工具里面执行看看有数据么
    2021-11-30 16:20 
  • Z4u3z1 Z4u3z1 回复 zhangjinrui(提问者) ???
    2021-12-01 14:10 
  • zhangjinrui zhangjinrui(提问者) 回复 Z4u3z1 还是显示不出来
    2021-12-01 16:28 
  • Z4u3z1 Z4u3z1 回复 zhangjinrui(提问者) 私信你了
    2021-12-01 16:31 
最佳回答
0
elaizaLv6初级互助
发布于2021-11-30 15:36

{call SP_REPORTRESULTD --存储过程名

(

-- 参数

'COM0210',

'${开始日期}',

'${结束日期}',

'${对比开始日期}',

'${对比结束日期}',

-- ?来接收返回的游标数据

?, 

)}

  • 2关注人数
  • 384浏览人数
  • 最后回答于:2021-11-30 16:18
    请选择关闭问题的原因
    确定 取消
    返回顶部