UFN_OPPORTUNITY_DESIGNATIONLIST
Returns the fundraising purposes for an opportunity.
Return
Return Type |
---|
nvarchar(1000) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@OPPORTUNITYID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_OPPORTUNITY_DESIGNATIONLIST(@OPPORTUNITYID uniqueidentifier)
returns nvarchar(1000)
with execute as caller
as begin
declare @LIST nvarchar(1000)
declare @NAME nvarchar(100)
declare @DESIGNATIONS table
(
DESIGNATIONID uniqueidentifier,
SEQUENCE int
);
insert into @DESIGNATIONS(DESIGNATIONID, SEQUENCE)
select distinct
DESIGNATIONID,
min(SEQUENCE)
from dbo.OPPORTUNITYDESIGNATION
where OPPORTUNITYID = @OPPORTUNITYID and
DESIGNATIONID is not null
group by DESIGNATIONID
declare CUR cursor local fast_forward for
select
dbo.UFN_DESIGNATION_BUILDNAME([D].DESIGNATIONID)
from @DESIGNATIONS [D]
order by [D].SEQUENCE
open CUR
fetch next from CUR into @NAME
while @@fetch_status = 0 begin
if @LIST is null
set @LIST = @NAME
else
set @LIST = @LIST + N', ' + @NAME
fetch next from CUR into @NAME
end
close CUR
deallocate CUR
return @LIST
end