UFN_TEAMFUNDRAISINGTEAM_BUILDFULLNAME
Return
Return Type |
---|
nvarchar(1009) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN |
Definition
Copy
create function dbo.UFN_TEAMFUNDRAISINGTEAM_BUILDFULLNAME
(
@ID uniqueidentifier
)
returns nvarchar(1009)
with execute as caller
as
begin
declare @FULLNAME nvarchar(1009);
select
@FULLNAME =
(
case when T10.PARENTTEAMID is not null then '...\' else '' end
+ case when T10.NAME is not null then (T10.NAME + '\') else '' end
+ case when T9.NAME is not null then (T9.NAME + '\') else '' end
+ case when T8.NAME is not null then (T8.NAME + '\') else '' end
+ case when T7.NAME is not null then (T7.NAME + '\') else '' end
+ case when T6.NAME is not null then (T6.NAME + '\') else '' end
+ case when T5.NAME is not null then (T5.NAME + '\') else '' end
+ case when T4.NAME is not null then (T4.NAME + '\') else '' end
+ case when T3.NAME is not null then (T3.NAME + '\') else '' end
+ case when T2.NAME is not null then (T2.NAME + '\') else '' end
+ T1.NAME
)
from
dbo.TEAMFUNDRAISINGTEAM T1
left join dbo.TEAMFUNDRAISINGTEAM T2 on T1.PARENTTEAMID = T2.ID
left join dbo.TEAMFUNDRAISINGTEAM T3 on T2.PARENTTEAMID = T3.ID
left join dbo.TEAMFUNDRAISINGTEAM T4 on T3.PARENTTEAMID = T4.ID
left join dbo.TEAMFUNDRAISINGTEAM T5 on T4.PARENTTEAMID = T5.ID
left join dbo.TEAMFUNDRAISINGTEAM T6 on T5.PARENTTEAMID = T6.ID
left join dbo.TEAMFUNDRAISINGTEAM T7 on T6.PARENTTEAMID = T7.ID
left join dbo.TEAMFUNDRAISINGTEAM T8 on T7.PARENTTEAMID = T8.ID
left join dbo.TEAMFUNDRAISINGTEAM T9 on T8.PARENTTEAMID = T9.ID
left join dbo.TEAMFUNDRAISINGTEAM T10 on T9.PARENTTEAMID = T10.ID
where
T1.ID = @ID;
return @FULLNAME
end