USP_FAFEVENT_GETEVENTSPONSORSHIPOPTION_UPDATEFROMXML
Used to update a set of records defined by UFN_FAFEVENT_GETEVENTSPONSORSHIPOPTION from the given xml string.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@EVENTID | uniqueidentifier | IN | |
@XML | xml | IN | |
@CHANGEAGENTID | uniqueidentifier | IN | |
@CHANGEDATE | datetime | IN |
Definition
Copy
/*
Generated by Blackbaud AppFx Platform
Date: 8/17/2011 2:26:52 PM
Assembly Version: Blackbaud.AppFx.Platform.SqlClr, Version=2.91.1535.0, Culture=neutral, PublicKeyToken=null
Copyright Blackbaud
*/
CREATE PROCEDURE dbo.USP_FAFEVENT_GETEVENTSPONSORSHIPOPTION_UPDATEFROMXML
(
@EVENTID uniqueidentifier,
@XML xml,
@CHANGEAGENTID uniqueidentifier = null,
@CHANGEDATE datetime = null
)
as
set nocount on;
if @CHANGEAGENTID is null
exec USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
if @CHANGEDATE is null
set @CHANGEDATE = getdate()
-- build a temporary table containing the values from the XML
declare @TempTbl table (
[ALLOWSPONSORWAIVEBENEFITS] bit,
[COMMUNICATIONS] int,
[COPYBATCHGUID] uniqueidentifier,
[COPYSOURCEID] uniqueidentifier,
[DESCRIPTION] nvarchar(1000),
[DISPLAYSPOTSAVAILABLE] bit,
[DONORRETENTION] decimal(7, 2),
[EARLYREGISTRATIONDATE] int,
[EARLYREGISTRATIONDISCOUNT] money,
[FEESAMOUNT] money,
[ID] varchar(36),
[ISACTIVE] bit,
[ISNOTAVAILABLEONLINEREG] bit,
[ISNOTLOWERCOMMUNICATION] bit,
[ISNOTLOWERDONORRETENTION] bit,
[ISNOTLOWERFUNDRAISINGGOAL] bit,
[ISNOTLOWERRECRUITEMENT] bit,
[ISNOTLOWERUNIT] bit,
[ISNOTLOWERVOLUNTEERRECRUITEMENT] bit,
[LABELFORUNITGOAL] nvarchar(50),
[LATEFEE] money,
[LATEFEEDATE] int,
[MINFUNDRAISINGGOAL] money,
[NAME] nvarchar(50),
[NUMBERAVAILABLE] int,
[RECRUITEMENT] int,
[SENDEVENTCONTACTALERTMAXREACHED] bit,
[SPONSORMUSTPAYBALANCE] bit,
[SPONSORPAYSBALANCEMESSAGE] nvarchar(1000),
[TAXDEDUCTIBLEAMOUNT] money,
[TURNONWAITLIST] bit,
[UNIT] int,
[VOLUNTEERRECRUITEMENT] int,
[WAITLISTMESSAGE] nvarchar(1000))
insert into @TempTbl select
[ALLOWSPONSORWAIVEBENEFITS],
[COMMUNICATIONS],
[COPYBATCHGUID],
[COPYSOURCEID],
[DESCRIPTION],
[DISPLAYSPOTSAVAILABLE],
[DONORRETENTION],
[EARLYREGISTRATIONDATE],
[EARLYREGISTRATIONDISCOUNT],
[FEESAMOUNT],
[ID],
[ISACTIVE],
[ISNOTAVAILABLEONLINEREG],
[ISNOTLOWERCOMMUNICATION],
[ISNOTLOWERDONORRETENTION],
[ISNOTLOWERFUNDRAISINGGOAL],
[ISNOTLOWERRECRUITEMENT],
[ISNOTLOWERUNIT],
[ISNOTLOWERVOLUNTEERRECRUITEMENT],
[LABELFORUNITGOAL],
[LATEFEE],
[LATEFEEDATE],
[MINFUNDRAISINGGOAL],
[NAME],
[NUMBERAVAILABLE],
[RECRUITEMENT],
[SENDEVENTCONTACTALERTMAXREACHED],
[SPONSORMUSTPAYBALANCE],
[SPONSORPAYSBALANCEMESSAGE],
[TAXDEDUCTIBLEAMOUNT],
[TURNONWAITLIST],
[UNIT],
[VOLUNTEERRECRUITEMENT],
[WAITLISTMESSAGE]
from dbo.UFN_FAFEVENT_GETEVENTSPONSORSHIPOPTION_FROMITEMLISTXML(@XML)
update @TempTbl set ID = newid() where (ID is null) or (ID = '00000000-0000-0000-0000-000000000000');
if @@Error <> 0
return 1;
declare @contextCache varbinary(128);
declare @e int;
-- cache current context information
set @contextCache = CONTEXT_INFO();
-- set CONTEXT_INFO to @CHANGEAGENTID
if not @CHANGEAGENTID is null
set CONTEXT_INFO @CHANGEAGENTID;
-- delete any items that no longer exist in the XML table
delete from dbo.[EVENTSPONSORSHIPTYPE] where [EVENTSPONSORSHIPTYPE].ID in
(select ID from dbo.UFN_FAFEVENT_GETEVENTSPONSORSHIPOPTION
(
@EVENTID
)
EXCEPT select ID from @TempTbl)
select @e=@@error;
-- reset CONTEXT_INFO to previous value
if not @contextCache is null
set CONTEXT_INFO @contextCache;
if @e <> 0
return 2;
-- update the items that exist in the XML table and the db
update [EVENTSPONSORSHIPTYPE]
set [EVENTSPONSORSHIPTYPE].[ALLOWSPONSORWAIVEBENEFITS]=temp.[ALLOWSPONSORWAIVEBENEFITS],
[EVENTSPONSORSHIPTYPE].[COMMUNICATIONS]=temp.[COMMUNICATIONS],
[EVENTSPONSORSHIPTYPE].[COPYBATCHGUID]=temp.[COPYBATCHGUID],
[EVENTSPONSORSHIPTYPE].[COPYSOURCEID]=temp.[COPYSOURCEID],
[EVENTSPONSORSHIPTYPE].[DESCRIPTION]=temp.[DESCRIPTION],
[EVENTSPONSORSHIPTYPE].[DISPLAYSPOTSAVAILABLE]=temp.[DISPLAYSPOTSAVAILABLE],
[EVENTSPONSORSHIPTYPE].[DONORRETENTION]=temp.[DONORRETENTION],
[EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDATE]=temp.[EARLYREGISTRATIONDATE],
[EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDISCOUNT]=temp.[EARLYREGISTRATIONDISCOUNT],
[EVENTSPONSORSHIPTYPE].[FEESAMOUNT]=temp.[FEESAMOUNT],
[EVENTSPONSORSHIPTYPE].[ID]=temp.[ID],
[EVENTSPONSORSHIPTYPE].[ISACTIVE]=temp.[ISACTIVE],
[EVENTSPONSORSHIPTYPE].[ISNOTAVAILABLEONLINEREG]=temp.[ISNOTAVAILABLEONLINEREG],
[EVENTSPONSORSHIPTYPE].[ISNOTLOWERCOMMUNICATION]=temp.[ISNOTLOWERCOMMUNICATION],
[EVENTSPONSORSHIPTYPE].[ISNOTLOWERDONORRETENTION]=temp.[ISNOTLOWERDONORRETENTION],
[EVENTSPONSORSHIPTYPE].[ISNOTLOWERFUNDRAISINGGOAL]=temp.[ISNOTLOWERFUNDRAISINGGOAL],
[EVENTSPONSORSHIPTYPE].[ISNOTLOWERRECRUITEMENT]=temp.[ISNOTLOWERRECRUITEMENT],
[EVENTSPONSORSHIPTYPE].[ISNOTLOWERUNIT]=temp.[ISNOTLOWERUNIT],
[EVENTSPONSORSHIPTYPE].[ISNOTLOWERVOLUNTEERRECRUITEMENT]=temp.[ISNOTLOWERVOLUNTEERRECRUITEMENT],
[EVENTSPONSORSHIPTYPE].[LABELFORUNITGOAL]=temp.[LABELFORUNITGOAL],
[EVENTSPONSORSHIPTYPE].[LATEFEE]=temp.[LATEFEE],
[EVENTSPONSORSHIPTYPE].[LATEFEEDATE]=temp.[LATEFEEDATE],
[EVENTSPONSORSHIPTYPE].[MINFUNDRAISINGGOAL]=temp.[MINFUNDRAISINGGOAL],
[EVENTSPONSORSHIPTYPE].[NAME]=temp.[NAME],
[EVENTSPONSORSHIPTYPE].[NUMBERAVAILABLE]=temp.[NUMBERAVAILABLE],
[EVENTSPONSORSHIPTYPE].[RECRUITEMENT]=temp.[RECRUITEMENT],
[EVENTSPONSORSHIPTYPE].[SENDEVENTCONTACTALERTMAXREACHED]=temp.[SENDEVENTCONTACTALERTMAXREACHED],
[EVENTSPONSORSHIPTYPE].[SPONSORMUSTPAYBALANCE]=temp.[SPONSORMUSTPAYBALANCE],
[EVENTSPONSORSHIPTYPE].[SPONSORPAYSBALANCEMESSAGE]=temp.[SPONSORPAYSBALANCEMESSAGE],
[EVENTSPONSORSHIPTYPE].[TAXDEDUCTIBLEAMOUNT]=temp.[TAXDEDUCTIBLEAMOUNT],
[EVENTSPONSORSHIPTYPE].[TURNONWAITLIST]=temp.[TURNONWAITLIST],
[EVENTSPONSORSHIPTYPE].[UNIT]=temp.[UNIT],
[EVENTSPONSORSHIPTYPE].[VOLUNTEERRECRUITEMENT]=temp.[VOLUNTEERRECRUITEMENT],
[EVENTSPONSORSHIPTYPE].[WAITLISTMESSAGE]=temp.[WAITLISTMESSAGE],
[EVENTSPONSORSHIPTYPE].CHANGEDBYID = @CHANGEAGENTID,
[EVENTSPONSORSHIPTYPE].DATECHANGED = @CHANGEDATE
from dbo.[EVENTSPONSORSHIPTYPE] inner join @TempTbl as [temp] on [EVENTSPONSORSHIPTYPE].ID = [temp].ID
where ([EVENTSPONSORSHIPTYPE].[ALLOWSPONSORWAIVEBENEFITS]<>temp.[ALLOWSPONSORWAIVEBENEFITS]) or
([EVENTSPONSORSHIPTYPE].[ALLOWSPONSORWAIVEBENEFITS] is null and temp.[ALLOWSPONSORWAIVEBENEFITS] is not null) or
([EVENTSPONSORSHIPTYPE].[ALLOWSPONSORWAIVEBENEFITS] is not null and temp.[ALLOWSPONSORWAIVEBENEFITS] is null) or
([EVENTSPONSORSHIPTYPE].[COMMUNICATIONS]<>temp.[COMMUNICATIONS]) or
([EVENTSPONSORSHIPTYPE].[COMMUNICATIONS] is null and temp.[COMMUNICATIONS] is not null) or
([EVENTSPONSORSHIPTYPE].[COMMUNICATIONS] is not null and temp.[COMMUNICATIONS] is null) or
([EVENTSPONSORSHIPTYPE].[COPYBATCHGUID]<>temp.[COPYBATCHGUID]) or
([EVENTSPONSORSHIPTYPE].[COPYBATCHGUID] is null and temp.[COPYBATCHGUID] is not null) or
([EVENTSPONSORSHIPTYPE].[COPYBATCHGUID] is not null and temp.[COPYBATCHGUID] is null) or
([EVENTSPONSORSHIPTYPE].[COPYSOURCEID]<>temp.[COPYSOURCEID]) or
([EVENTSPONSORSHIPTYPE].[COPYSOURCEID] is null and temp.[COPYSOURCEID] is not null) or
([EVENTSPONSORSHIPTYPE].[COPYSOURCEID] is not null and temp.[COPYSOURCEID] is null) or
([EVENTSPONSORSHIPTYPE].[DESCRIPTION]<>temp.[DESCRIPTION]) or
([EVENTSPONSORSHIPTYPE].[DESCRIPTION] is null and temp.[DESCRIPTION] is not null) or
([EVENTSPONSORSHIPTYPE].[DESCRIPTION] is not null and temp.[DESCRIPTION] is null) or
([EVENTSPONSORSHIPTYPE].[DISPLAYSPOTSAVAILABLE]<>temp.[DISPLAYSPOTSAVAILABLE]) or
([EVENTSPONSORSHIPTYPE].[DISPLAYSPOTSAVAILABLE] is null and temp.[DISPLAYSPOTSAVAILABLE] is not null) or
([EVENTSPONSORSHIPTYPE].[DISPLAYSPOTSAVAILABLE] is not null and temp.[DISPLAYSPOTSAVAILABLE] is null) or
([EVENTSPONSORSHIPTYPE].[DONORRETENTION]<>temp.[DONORRETENTION]) or
([EVENTSPONSORSHIPTYPE].[DONORRETENTION] is null and temp.[DONORRETENTION] is not null) or
([EVENTSPONSORSHIPTYPE].[DONORRETENTION] is not null and temp.[DONORRETENTION] is null) or
([EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDATE]<>temp.[EARLYREGISTRATIONDATE]) or
([EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDATE] is null and temp.[EARLYREGISTRATIONDATE] is not null) or
([EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDATE] is not null and temp.[EARLYREGISTRATIONDATE] is null) or
([EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDISCOUNT]<>temp.[EARLYREGISTRATIONDISCOUNT]) or
([EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDISCOUNT] is null and temp.[EARLYREGISTRATIONDISCOUNT] is not null) or
([EVENTSPONSORSHIPTYPE].[EARLYREGISTRATIONDISCOUNT] is not null and temp.[EARLYREGISTRATIONDISCOUNT] is null) or
([EVENTSPONSORSHIPTYPE].[FEESAMOUNT]<>temp.[FEESAMOUNT]) or
([EVENTSPONSORSHIPTYPE].[FEESAMOUNT] is null and temp.[FEESAMOUNT] is not null) or
([EVENTSPONSORSHIPTYPE].[FEESAMOUNT] is not null and temp.[FEESAMOUNT] is null) or
([EVENTSPONSORSHIPTYPE].[ID]<>temp.[ID]) or
([EVENTSPONSORSHIPTYPE].[ID] is null and temp.[ID] is not null) or
([EVENTSPONSORSHIPTYPE].[ID] is not null and temp.[ID] is null) or
([EVENTSPONSORSHIPTYPE].[ISACTIVE]<>temp.[ISACTIVE]) or
([EVENTSPONSORSHIPTYPE].[ISACTIVE] is null and temp.[ISACTIVE] is not null) or
([EVENTSPONSORSHIPTYPE].[ISACTIVE] is not null and temp.[ISACTIVE] is null) or
([EVENTSPONSORSHIPTYPE].[ISNOTAVAILABLEONLINEREG]<>temp.[ISNOTAVAILABLEONLINEREG]) or
([EVENTSPONSORSHIPTYPE].[ISNOTAVAILABLEONLINEREG] is null and temp.[ISNOTAVAILABLEONLINEREG] is not null) or
([EVENTSPONSORSHIPTYPE].[ISNOTAVAILABLEONLINEREG] is not null and temp.[ISNOTAVAILABLEONLINEREG] is null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERCOMMUNICATION]<>temp.[ISNOTLOWERCOMMUNICATION]) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERCOMMUNICATION] is null and temp.[ISNOTLOWERCOMMUNICATION] is not null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERCOMMUNICATION] is not null and temp.[ISNOTLOWERCOMMUNICATION] is null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERDONORRETENTION]<>temp.[ISNOTLOWERDONORRETENTION]) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERDONORRETENTION] is null and temp.[ISNOTLOWERDONORRETENTION] is not null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERDONORRETENTION] is not null and temp.[ISNOTLOWERDONORRETENTION] is null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERFUNDRAISINGGOAL]<>temp.[ISNOTLOWERFUNDRAISINGGOAL]) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERFUNDRAISINGGOAL] is null and temp.[ISNOTLOWERFUNDRAISINGGOAL] is not null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERFUNDRAISINGGOAL] is not null and temp.[ISNOTLOWERFUNDRAISINGGOAL] is null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERRECRUITEMENT]<>temp.[ISNOTLOWERRECRUITEMENT]) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERRECRUITEMENT] is null and temp.[ISNOTLOWERRECRUITEMENT] is not null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERRECRUITEMENT] is not null and temp.[ISNOTLOWERRECRUITEMENT] is null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERUNIT]<>temp.[ISNOTLOWERUNIT]) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERUNIT] is null and temp.[ISNOTLOWERUNIT] is not null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERUNIT] is not null and temp.[ISNOTLOWERUNIT] is null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERVOLUNTEERRECRUITEMENT]<>temp.[ISNOTLOWERVOLUNTEERRECRUITEMENT]) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERVOLUNTEERRECRUITEMENT] is null and temp.[ISNOTLOWERVOLUNTEERRECRUITEMENT] is not null) or
([EVENTSPONSORSHIPTYPE].[ISNOTLOWERVOLUNTEERRECRUITEMENT] is not null and temp.[ISNOTLOWERVOLUNTEERRECRUITEMENT] is null) or
([EVENTSPONSORSHIPTYPE].[LABELFORUNITGOAL]<>temp.[LABELFORUNITGOAL]) or
([EVENTSPONSORSHIPTYPE].[LABELFORUNITGOAL] is null and temp.[LABELFORUNITGOAL] is not null) or
([EVENTSPONSORSHIPTYPE].[LABELFORUNITGOAL] is not null and temp.[LABELFORUNITGOAL] is null) or
([EVENTSPONSORSHIPTYPE].[LATEFEE]<>temp.[LATEFEE]) or
([EVENTSPONSORSHIPTYPE].[LATEFEE] is null and temp.[LATEFEE] is not null) or
([EVENTSPONSORSHIPTYPE].[LATEFEE] is not null and temp.[LATEFEE] is null) or
([EVENTSPONSORSHIPTYPE].[LATEFEEDATE]<>temp.[LATEFEEDATE]) or
([EVENTSPONSORSHIPTYPE].[LATEFEEDATE] is null and temp.[LATEFEEDATE] is not null) or
([EVENTSPONSORSHIPTYPE].[LATEFEEDATE] is not null and temp.[LATEFEEDATE] is null) or
([EVENTSPONSORSHIPTYPE].[MINFUNDRAISINGGOAL]<>temp.[MINFUNDRAISINGGOAL]) or
([EVENTSPONSORSHIPTYPE].[MINFUNDRAISINGGOAL] is null and temp.[MINFUNDRAISINGGOAL] is not null) or
([EVENTSPONSORSHIPTYPE].[MINFUNDRAISINGGOAL] is not null and temp.[MINFUNDRAISINGGOAL] is null) or
([EVENTSPONSORSHIPTYPE].[NAME]<>temp.[NAME]) or
([EVENTSPONSORSHIPTYPE].[NAME] is null and temp.[NAME] is not null) or
([EVENTSPONSORSHIPTYPE].[NAME] is not null and temp.[NAME] is null) or
([EVENTSPONSORSHIPTYPE].[NUMBERAVAILABLE]<>temp.[NUMBERAVAILABLE]) or
([EVENTSPONSORSHIPTYPE].[NUMBERAVAILABLE] is null and temp.[NUMBERAVAILABLE] is not null) or
([EVENTSPONSORSHIPTYPE].[NUMBERAVAILABLE] is not null and temp.[NUMBERAVAILABLE] is null) or
([EVENTSPONSORSHIPTYPE].[RECRUITEMENT]<>temp.[RECRUITEMENT]) or
([EVENTSPONSORSHIPTYPE].[RECRUITEMENT] is null and temp.[RECRUITEMENT] is not null) or
([EVENTSPONSORSHIPTYPE].[RECRUITEMENT] is not null and temp.[RECRUITEMENT] is null) or
([EVENTSPONSORSHIPTYPE].[SENDEVENTCONTACTALERTMAXREACHED]<>temp.[SENDEVENTCONTACTALERTMAXREACHED]) or
([EVENTSPONSORSHIPTYPE].[SENDEVENTCONTACTALERTMAXREACHED] is null and temp.[SENDEVENTCONTACTALERTMAXREACHED] is not null) or
([EVENTSPONSORSHIPTYPE].[SENDEVENTCONTACTALERTMAXREACHED] is not null and temp.[SENDEVENTCONTACTALERTMAXREACHED] is null) or
([EVENTSPONSORSHIPTYPE].[SPONSORMUSTPAYBALANCE]<>temp.[SPONSORMUSTPAYBALANCE]) or
([EVENTSPONSORSHIPTYPE].[SPONSORMUSTPAYBALANCE] is null and temp.[SPONSORMUSTPAYBALANCE] is not null) or
([EVENTSPONSORSHIPTYPE].[SPONSORMUSTPAYBALANCE] is not null and temp.[SPONSORMUSTPAYBALANCE] is null) or
([EVENTSPONSORSHIPTYPE].[SPONSORPAYSBALANCEMESSAGE]<>temp.[SPONSORPAYSBALANCEMESSAGE]) or
([EVENTSPONSORSHIPTYPE].[SPONSORPAYSBALANCEMESSAGE] is null and temp.[SPONSORPAYSBALANCEMESSAGE] is not null) or
([EVENTSPONSORSHIPTYPE].[SPONSORPAYSBALANCEMESSAGE] is not null and temp.[SPONSORPAYSBALANCEMESSAGE] is null) or
([EVENTSPONSORSHIPTYPE].[TAXDEDUCTIBLEAMOUNT]<>temp.[TAXDEDUCTIBLEAMOUNT]) or
([EVENTSPONSORSHIPTYPE].[TAXDEDUCTIBLEAMOUNT] is null and temp.[TAXDEDUCTIBLEAMOUNT] is not null) or
([EVENTSPONSORSHIPTYPE].[TAXDEDUCTIBLEAMOUNT] is not null and temp.[TAXDEDUCTIBLEAMOUNT] is null) or
([EVENTSPONSORSHIPTYPE].[TURNONWAITLIST]<>temp.[TURNONWAITLIST]) or
([EVENTSPONSORSHIPTYPE].[TURNONWAITLIST] is null and temp.[TURNONWAITLIST] is not null) or
([EVENTSPONSORSHIPTYPE].[TURNONWAITLIST] is not null and temp.[TURNONWAITLIST] is null) or
([EVENTSPONSORSHIPTYPE].[UNIT]<>temp.[UNIT]) or
([EVENTSPONSORSHIPTYPE].[UNIT] is null and temp.[UNIT] is not null) or
([EVENTSPONSORSHIPTYPE].[UNIT] is not null and temp.[UNIT] is null) or
([EVENTSPONSORSHIPTYPE].[VOLUNTEERRECRUITEMENT]<>temp.[VOLUNTEERRECRUITEMENT]) or
([EVENTSPONSORSHIPTYPE].[VOLUNTEERRECRUITEMENT] is null and temp.[VOLUNTEERRECRUITEMENT] is not null) or
([EVENTSPONSORSHIPTYPE].[VOLUNTEERRECRUITEMENT] is not null and temp.[VOLUNTEERRECRUITEMENT] is null) or
([EVENTSPONSORSHIPTYPE].[WAITLISTMESSAGE]<>temp.[WAITLISTMESSAGE]) or
([EVENTSPONSORSHIPTYPE].[WAITLISTMESSAGE] is null and temp.[WAITLISTMESSAGE] is not null) or
([EVENTSPONSORSHIPTYPE].[WAITLISTMESSAGE] is not null and temp.[WAITLISTMESSAGE] is null)
if @@Error <> 0
return 3;
-- insert new items
insert into [EVENTSPONSORSHIPTYPE]
([EVENTID],
[ALLOWSPONSORWAIVEBENEFITS],
[COMMUNICATIONS],
[COPYBATCHGUID],
[COPYSOURCEID],
[DESCRIPTION],
[DISPLAYSPOTSAVAILABLE],
[DONORRETENTION],
[EARLYREGISTRATIONDATE],
[EARLYREGISTRATIONDISCOUNT],
[FEESAMOUNT],
[ID],
[ISACTIVE],
[ISNOTAVAILABLEONLINEREG],
[ISNOTLOWERCOMMUNICATION],
[ISNOTLOWERDONORRETENTION],
[ISNOTLOWERFUNDRAISINGGOAL],
[ISNOTLOWERRECRUITEMENT],
[ISNOTLOWERUNIT],
[ISNOTLOWERVOLUNTEERRECRUITEMENT],
[LABELFORUNITGOAL],
[LATEFEE],
[LATEFEEDATE],
[MINFUNDRAISINGGOAL],
[NAME],
[NUMBERAVAILABLE],
[RECRUITEMENT],
[SENDEVENTCONTACTALERTMAXREACHED],
[SPONSORMUSTPAYBALANCE],
[SPONSORPAYSBALANCEMESSAGE],
[TAXDEDUCTIBLEAMOUNT],
[TURNONWAITLIST],
[UNIT],
[VOLUNTEERRECRUITEMENT],
[WAITLISTMESSAGE],
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED)
select @EVENTID,
[ALLOWSPONSORWAIVEBENEFITS],
[COMMUNICATIONS],
[COPYBATCHGUID],
[COPYSOURCEID],
[DESCRIPTION],
[DISPLAYSPOTSAVAILABLE],
[DONORRETENTION],
[EARLYREGISTRATIONDATE],
[EARLYREGISTRATIONDISCOUNT],
[FEESAMOUNT],
[ID],
[ISACTIVE],
[ISNOTAVAILABLEONLINEREG],
[ISNOTLOWERCOMMUNICATION],
[ISNOTLOWERDONORRETENTION],
[ISNOTLOWERFUNDRAISINGGOAL],
[ISNOTLOWERRECRUITEMENT],
[ISNOTLOWERUNIT],
[ISNOTLOWERVOLUNTEERRECRUITEMENT],
[LABELFORUNITGOAL],
[LATEFEE],
[LATEFEEDATE],
[MINFUNDRAISINGGOAL],
[NAME],
[NUMBERAVAILABLE],
[RECRUITEMENT],
[SENDEVENTCONTACTALERTMAXREACHED],
[SPONSORMUSTPAYBALANCE],
[SPONSORPAYSBALANCEMESSAGE],
[TAXDEDUCTIBLEAMOUNT],
[TURNONWAITLIST],
[UNIT],
[VOLUNTEERRECRUITEMENT],
[WAITLISTMESSAGE],
@CHANGEAGENTID,
@CHANGEAGENTID,
@CHANGEDATE,
@CHANGEDATE
from @TempTbl as [temp]
where not exists (select ID from dbo.[EVENTSPONSORSHIPTYPE] as data where data.ID = [temp].ID)
if @@Error <> 0
return 4;
return 0;