Can T-SQL function return user-defined table type?
15,267
As far as I understand Microsoft's MSDN article here, those user-defined table types are only available as read-only parameters to stored procedures or stored functions.
It doesn't mention anything that they could be used to be returned from a user-defined function, unfortunately - so I guess you're right - it's not possible (at least not now).
Author by
abatishchev
This is my GUID. There are many like it but this one is mine. My GUID is my best friend. It is my life. I must master it as I must master my life. Without me, my GUID is useless. Without my GUID I am useless.
Updated on July 02, 2022Comments
-
abatishchev almost 2 years
I have my own type:
CREATE TYPE MyType AS TABLE ( foo INT )
and a function receiving it as a parameter:
CREATE FUNCTION Test ( @in MyType READONLY ) RETURNS @return MyType AS ...
can it return
MyType
or onlyTABLE
repeating MyType's structure:CREATE FUNCTION Test ( @in MyType READONLY ) RETURNS @return TABLE (foo INT) AS ...
?