Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
创建一个UDT,该UDT的成员为SQL@tables_Sql_Sql Server 2008_Table Valued Parameters_User Defined Types - Fatal编程技术网

创建一个UDT,该UDT的成员为SQL@tables

创建一个UDT,该UDT的成员为SQL@tables,sql,sql-server-2008,table-valued-parameters,user-defined-types,Sql,Sql Server 2008,Table Valued Parameters,User Defined Types,我想知道是否有可能在SQLServer2008中创建一个CLR用户定义类型,其中的成员将是表变量 您知道,您可以声明一个表变量: declare @foo table (row_id int not null ... ); 因此,我认为UDT有几个成员,每个成员都是以这种方式定义的表(当然是不同的表),因此可以说: select id from @typed_var.table1 where ... 或 我确实有一种感觉,我对这件事想得太多了,但在互联网上似乎找不到一个明确的是或不是。 可能

我想知道是否有可能在SQLServer2008中创建一个CLR用户定义类型,其中的成员将是表变量

您知道,您可以声明一个表变量:

declare @foo table (row_id int not null ... );
因此,我认为UDT有几个成员,每个成员都是以这种方式定义的表(当然是不同的表),因此可以说:

select id from @typed_var.table1 where ...

我确实有一种感觉,我对这件事想得太多了,但在互联网上似乎找不到一个明确的是或不是。

可能吗?

不,这是不可能的。SQL server不允许您选择或插入UDT的属性

我尝试了这个,得到了如下错误:

create type childTable as table
(
    a int,
    b int
)

create type childTable2 as table
(
    c int
)

create type parentTable as table
(
    firstChild childTable,
    secondChild childTable2
)

Msg 350, Level 16, State 1, Line 1
The column "firstChild" does not have a valid data type. A column cannot be of a user-defined table type.

我认为这个问题是相关的:这篇文章有一些非常有用的东西:
create type childTable as table
(
    a int,
    b int
)

create type childTable2 as table
(
    c int
)

create type parentTable as table
(
    firstChild childTable,
    secondChild childTable2
)

Msg 350, Level 16, State 1, Line 1
The column "firstChild" does not have a valid data type. A column cannot be of a user-defined table type.