USP_UPDATE_EMAILADDRESS_OPTOUT_STATUS

Parameters

Parameter Parameter Type Mode Description
@EMAILADDRESS UDT_EMAILADDRESS IN
@HASOPTEDOUT bit IN

Definition

Copy


create procedure dbo.USP_UPDATE_EMAILADDRESS_OPTOUT_STATUS
(
   @EMAILADDRESS UDT_EMAILADDRESS,
   @HASOPTEDOUT bit
)
as
begin
     --update non-constituents

    --also do this to keep track of constituents because multiple constits can have the same email

    merge dbo.EmailList_GlobalSubscription as target
    using
    (
        select @EMAILADDRESS EMAILADDRESS, @HASOPTEDOUT HASOPTED
    ) as source
    on (target.EmailAddress = source.EMAILADDRESS)

    when matched then
        update set HasOpted=source.HASOPTED

    when NOT matched by target then
        insert (EmailAddress, HasOpted) values (source.EMAILADDRESS, source.HASOPTED);
end