UFN_EVENT_GETLOCATIONNAME
This function returns the location names for an event.
Return
Return Type |
---|
nvarchar(500) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_EVENT_GETLOCATIONNAME
(
@ID uniqueidentifier
)
returns nvarchar(500)
with execute as caller
as begin
declare @EVENTLOCATIONID uniqueidentifier;
declare @LOCATION nvarchar(500);
select @EVENTLOCATIONID=EVENTLOCATIONID
from dbo.EVENT
where ID=@ID;
if @EVENTLOCATIONID is not null
begin
select @LOCATION=NAME from dbo.EVENTLOCATION
where ID=@EVENTLOCATIONID
end
else
begin
declare @EVENTLOCATIONS table (NAME nvarchar(100));
insert @EVENTLOCATIONS (NAME)
select EVENTLOCATION.NAME
from dbo.PROGRAMEVENTLOCATION
inner join dbo.EVENTLOCATION on PROGRAMEVENTLOCATION.EVENTLOCATIONID = EVENTLOCATION.ID
where PROGRAMEVENTLOCATION.EVENTID = @ID
order by PROGRAMEVENTLOCATION.SEQUENCE;
select @LOCATION = dbo.UDA_BUILDLIST(NAME)
from @EVENTLOCATIONS;
end
return @LOCATION;
end