spFundRaiserTeamReport
Definition
Copy
CREATE procedure [dbo].[spFundRaiserTeamReport]
as
begin transaction
declare @rows int
declare @rows2 int
select @rows = count(*) from [dbo].[ReportFundraiserTeamData]
if (@rows>0)
begin
delete from [dbo].[ReportFundraiserTeamData]
end
insert into [dbo].[ReportFundraiserTeamData](
[FundraiserID],
[Fundraiser],
[TeamID],
[TeamName],
[TeamCaptainID],
[TeamCaptain],
[AmountRaised],
[Goal],
[TeamSize],
[ReportTimeStamp])
select
frt.RootFundraiserId FundraiserID,
scnt.title Fundraiser,
frt.id TeamID,
frt.name TeamName,
isnull(frt.CaptainID,0) TeamCaptainID,
case isnull(frt.CaptainID, 0)
when 0 then ''
else dbo.fnFundRaiserTeamCaptain(frt.CaptainID)
end TeamCaptain,
dbo.fnFundraiserTeamDonationTotal(frt.id, fr.id, 3) AmountRaised, --Team Levels restricted to 3
dbo.fnFundRaiserTeamGoal(frt.id, fr.id, 3) Goal, --Team Levels restricted to 3
dbo.fnFundRaiserTeamMemberCount(frt.id, fr.id, 3) TeamSize, --Team Levels restricted to 3
getutcdate()
from fundraiserTeams frt
inner join fundraisers fr on fr.id = frt.rootFundraiserId
inner join sitecontent scnt on scnt.id = fr.siteContentId
where fr.IsFunctional = 1 and fr.IsCarePageManager = 0
--Make a copy of the data in 2nd table
select @rows2 = count(*) from [dbo].[ReportFundraiserTeamData_Copy]
if (@rows2>0)
begin
delete from [dbo].[ReportFundraiserTeamData_Copy]
end
insert into [dbo].[ReportFundraiserTeamData_Copy](
[FundraiserID_Copy],
[Fundraiser_Copy],
[TeamID_Copy],
[TeamName_Copy],
[TeamCaptainID_Copy],
[TeamCaptain_Copy],
[AmountRaised_Copy],
[Goal_Copy],
[TeamSize_Copy],
[ReportTimeStamp_Copy])
select * from [dbo].[ReportFundraiserTeamData]
commit transaction