开发者

Can T-SQL function return user-defined table type? [duplicate]

This question already has answers here: SQL Server 2008: Can a multi-statement UDF return a UDT? [duplicate] (1 answer) SQL Server 2008 - How do i return a User-Defined Table Type from a Table-Valued Function? (4 answers) Closed 7 years ago.

I have my own type:

CREATE TYPE MyType AS TABLE
(
    foo INT
)

and a function receiving 开发者_JAVA百科it as a parameter:

CREATE FUNCTION Test
(
    @in MyType READONLY
)
RETURNS @return MyType
AS
...

can it return MyType or only TABLE repeating MyType's structure:

CREATE FUNCTION Test
(
    @in MyType READONLY
)
RETURNS @return TABLE (foo INT)
AS
...

?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜