T-SQL函数可以返回用户定义的表类型吗? [英] Can T-SQL function return user-defined table type?
问题描述
我有我自己的类型:
$ $ p $ CREATE TYPE MyType AS TABLE
(
foo INT
)
以及将它作为参数接收的函数:
CREATE FUNCTION测试
(
@in MyType READONLY
)
RETURNS @return MyType
AS
...
是否可以返回 ? 我了解微软的这里的MSDN文章,那些用户定义的表类型只是可用作存储过程或存储函数的只读参数。 不幸的是,它没有提及任何可以从用户定义函数返回的东西 - 所以我想你是对的 - 这是不可能的至少不是现在)。 I have my own type: and a function receiving it as a parameter: can it return ? 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). 这篇关于T-SQL函数可以返回用户定义的表类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! MyType
TABLE 重复MyType的结构:
$ p $
(
@in MyType READONLY
)
RETURNS @return TABLE(foo INT)
AS
...
CREATE TYPE MyType AS TABLE
(
foo INT
)
CREATE FUNCTION Test
(
@in MyType READONLY
)
RETURNS @return MyType
AS
...
MyType
or only TABLE
repeating MyType's structure:CREATE FUNCTION Test
(
@in MyType READONLY
)
RETURNS @return TABLE (foo INT)
AS
...