USP_REPORT_DIFFERENTIALDUPLICATECONSTITUENTSREPORT

Returns the data necessary for the Differential Duplicate Constituent Report

Definition

Copy


            create procedure dbo.USP_REPORT_DIFFERENTIALDUPLICATECONSTITUENTSREPORT
            with execute as owner
            as

            if exists(select name 
                      from   sysobjects 
                      where  name = N'FINDDIFFERENTIALDUPLICATERESULTS'
                      and   type = 'U')
            begin
                select
                    'http://www.blackbaud.com?CONSTITID=' + CONVERT(nvarchar(36),c.id) as CONSTITURL,
                    dupes._key_in as _key,
                    dupes._key_CONSTITID as CONSTITID,
                    dupes._score as _Similarity,
                    c.NAME + dbo.UFN_SUFFIXCODE_GETDESCRIPTION(c.SUFFIXCODEID) as NAME, 
                    dbo.UFN_BUILDFULLADDRESS(a.ID, a.ADDRESSBLOCK, a.CITY, a.STATEID, a.POSTCODE, a.COUNTRYID) as ADDRESS
                from
                    dbo.FINDDIFFERENTIALDUPLICATERESULTS dupes
                    inner join  dbo.CONSTITUENT c 
                    on c.ID = dupes.CONSTITID
                    left outer join dbo.ADDRESS a 
                    on a.CONSTITUENTID = c.ID and a.ISPRIMARY = 1
            end
            else
            begin
                declare @msg nvarchar(400)
                set @msg = 'You must successfully run the "Find Differential Duplicate Constituents" package in SQL Server Integration Services before running this report.  Contact your IT staff for assistance with running a package in SQL Server Integration Services.'
                RAISERROR (N'%s', 15, 1, @msg)
            end