CREATE TYPE dbo.itemList
AS TABLE
(
  item_cd varchar(50)
);
GO

create function dbo.fnc_test(@P_TBL dbo.itemList READONLY)
returns VARCHAR(MAX)
as
begin
        declare @R_VALUE VARCHAR(MAX);

        SELECT @R_VALUE = max(item_cd)
        FROM @P_TBL;

        return @R_VALUE;
end;
go




BEGIN

DECLARE @P_TBL AS dbo.itemList

insert into @P_TBL
select top 100
        item_cd
from esmmtgl;

select dbo.fnc_test(@P_TBL);

END;