UFN_MKTSELECTION_GETFUNCTIONNAME

Returns the function name for the selection that will return the selection IDs.

Return

Return Type
nvarchar(128)

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN

Definition

Copy


CREATE function dbo.[UFN_MKTSELECTION_GETFUNCTIONNAME]
(
  @ID uniqueidentifier
)
returns nvarchar(128)
as
begin
  declare @FUNCTIONNAME nvarchar(128);

  select @FUNCTIONNAME = [DBOBJECTNAME]
  from dbo.[IDSETREGISTER]
  where [ID] = @ID;

  --see if it is a function or a table

  if  exists (select 1 from SYS.OBJECTS where OBJECT_ID = object_id(@FUNCTIONNAME) and TYPE in (N'FN', N'IF', N'TF', N'FS', N'FT'))
    set @FUNCTIONNAME = '[' + @FUNCTIONNAME + ']()'; --function needs ()

  else
    set @FUNCTIONNAME = '[' + @FUNCTIONNAME + ']';-- table does not need ()


  return @FUNCTIONNAME;
end