UFN_REVENUEBATCHCONSTITUENT_BUILDNAME
Return
Return Type |
---|
nvarchar(700) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_REVENUEBATCHCONSTITUENT_BUILDNAME(@ID uniqueidentifier)
returns nvarchar(700)
as begin
if @ID is null
return '';
declare @name nvarchar(700);
with CONSTITUENTS (NAME) AS
(select NF.NAME from dbo.UFN_CONSTITUENT_DISPLAYNAME(@ID) NF
union
select NAME from dbo.BATCHREVENUECONSTITUENT where ID=@ID
-- BUG#584814: the details of a newly created spouse added to a constituent in batch are stored in a CUB-row
union
select (case SPOUSE_FIRSTNAME when '' then '' else SPOUSE_FIRSTNAME end) +
(case SPOUSE_MIDDLENAME when '' then '' else ' ' + LEFT(SPOUSE_MIDDLENAME,1) + '.' end) +
(case SPOUSE_LASTNAME when '' then '' else ' ' + SPOUSE_LASTNAME end) as NAME
from dbo.BATCHCONSTITUENTUPDATE where ID=@ID
)
select top 1 @name=NAME from CONSTITUENTS;
return coalesce(@name, '');
end