4

SQL Server 2008 のメンバーがテーブル変数になる CLR ユーザー定義型を作成できるかどうか疑問に思います。

ご存じのとおり、テーブル変数を宣言できます。

declare @foo table (row_id int not null ... );

だから私はいくつかのメンバーを持つUDTが好きで、それぞれがそのように定義されたテーブルです(もちろん別のテーブルです)ので、次のように言うことができます:

select id from @typed_var.table1 where ...

また

insert into @typed_var.table3(id) values (...)

私はこれについてあまりにも多くを望んでいると感じていますが、インターネット上で明確なYesまたはNoを見つけることができないようです.
それはまったく可能ですか?

4

1 に答える 1

1

いいえ、これは不可能です。SQL サーバーでは、UDT のプロパティに SELECT または INSERT を実行できません。

これを試したところ、以下のエラーが発生しました。

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.
于 2011-07-09T01:06:03.587 に答える