📄 cwfx_cashcompare.txt
字号:
--@Curr_date1,@Curr_date2 为当前时间段 @Comp_date1,@Comp_date2为比较期时间段
CREATE PROCEDURE dbo.cwfx_CashCompare @Curr_date1 datetime,@Curr_date2 datetime,@Comp_date1 datetime,@Comp_date2 datetime
AS
declare @ccode varchar(15),@Cname varchar(40),@Direction bit,@Curr_V money,@Comp_V money
--@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),Direction bit,Curr_V money,Comp_V money)
declare Budget_Cursor cursor for
Select Direction,CCode From cwfx_CashIncomeCostSet where year=year(@Curr_date1) order by direction,ccode
open Budget_Cursor
fetch next from Budget_Cursor into @Direction,@ccode
while (@@FETCH_STATUS = 0)
begin
select @Cname=Cname from cwzz_Acccode where ccode=@CCode
set @Curr_V=0
set @Comp_V=0
if @Direction=0 --0表示现金流入
select @Curr_V=sum(jfje) from cwzz_AccVouch where ccode=@ccode and VouchId in (select VouchId from Cwzz_AccVouchMain where DDate between @Curr_date1 and @Curr_date2)
else
select @Curr_V=sum(dfje) from cwzz_AccVouch where ccode=@ccode and VouchId in (select VouchId from Cwzz_AccVouchMain where DDate between @Curr_date1 and @Curr_date2)
if @Direction=0 --0表示现金流入
select @Comp_V=sum(jfje) from cwzz_AccVouch where ccode=@ccode and VouchId in (select VouchId from Cwzz_AccVouchMain where DDate between @Comp_date1 and @Comp_date2)
else
select @Comp_V=sum(dfje) from cwzz_AccVouch where ccode=@ccode and VouchId in (select VouchId from Cwzz_AccVouchMain where DDate between @Comp_date1 and @Comp_date2)
insert into ##temp values(@Ccode,@Cname,@Direction,@Curr_V,@Comp_V)
fetch next from Budget_Cursor into @Direction,@ccode
end
close Budget_Cursor
deallocate Budget_Cursor
--select * from ##temp
--drop table ##temp
END
GO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -