1

How to re-write the UDF returning table variable to the function returns memory-optimized type dbo.TypeOUT ?

DROP FUNCTION [dbo].[test01]
GO
CREATE  FUNCTION [dbo].[test01] (@id int)
    RETURNS @out table  (pid int,pname nvarchar(128))
AS
BEGIN
insert into @out(pid, pname) values(101, N'dobedo')
return;
END

CREATE TYPE dbo.TypeOUT AS TABLE  
(  
    id  int null,
    name nvarchar(128) null,
    RID    INT NOT  NULL  IDENTITY,  
    INDEX ix_RID HASH (RID) WITH (BUCKET_COUNT=1024)
   )   
   WITH (MEMORY_OPTIMIZED = ON);  
GO

select * from dbo.test01(1)
2
  • 1
    I don't believe the answer has changed since 2010. But I'd be really happy for somebody to show me otherwise. Commented Feb 19, 2021 at 3:20
  • You are right, me too ;-)
    – ZedZip
    Commented Feb 19, 2021 at 8:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.