📄 cwfx_deptcosta.txt
字号:
CREATE PROCEDURE dbo.cwfx_DeptCostA @DeptCode varchar(12),@CY int,@CM1 int,@CM2 int,@CmpY int=0,@CmpM1 int=0,@CmpM2 int=0
AS
declare @Flag char(2),@ccode varchar(15),@Cname varchar(40),@Curr_V money,@Comp_V money
BEGIN
if exists (select 1 from tempdb.dbo.sysobjects where name='##temp')
drop table ##temp
create table ##temp(Ccode varchar(15),Cname varchar(40),Curr_V money,Comp_V money)
declare Analysis_Cursor cursor for
Select distinct o.CCode From cwzz_AccSumAssi o,cwzz_Acccode m where o.ccode=m.ccode and o.deptcode=@deptcode and (o.year=@CY or o.year=@CmpY) and m.BalanceOri='借' order by o.Ccode
open Analysis_Cursor
fetch next from Analysis_Cursor into @ccode
while (@@FETCH_STATUS = 0)
begin
select @Cname=Cname from cwzz_Acccode where ccode=@CCode
set @Curr_V=0
set @Comp_V=0
select @Curr_V=sum(mjje) from cwzz_AccSumAssi where DeptCode=@DeptCode and ccode=@ccode and year=@cy and period between @cm1 and @cm2
if (@CmpY <>0 and @CmpM1 <>0 and @CmpM2<>0)
select @Comp_V=sum(mjje) from cwzz_AccSumAssi where DeptCode=@DeptCode and ccode=@ccode and year=@CmpY and period between @CmpM1 and @CmpM2
insert into ##temp values(@Ccode,@Cname,@Curr_V, @Comp_V)
fetch next from Analysis_Cursor into @ccode
end
close Analysis_Cursor
deallocate Analysis_Cursor
--select * from ##temp
--drop table ##temp
END
GO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -