別のデータベースにリンクされたサーバーを備えたSQLServerがあります。そのリンクサーバーにビューを作成しました
create view vw_foo as
select
[id],
[name]
from LINKEDSERVER.RemoteDatabase.dbo.tbl_bar
以下にしたいのですが
alter table [baz]
add foo_id int not null
go
alter table [baz] with check
add constraint [fk1_baz_to_foo]
foreign key([foo_id])
references [dbo].[vw_foo] ([id])
go
しかし、それはエラーを生成します:「外部キー'fk1_baz_to_foo'はユーザーテーブルではないオブジェクト'dbo.vw_foo'を参照します。」
次を使用して外部キーをテーブルに直接配置しようとすると
alter table [baz] with check
add constraint [fk1_baz_to_bar]
foreign key([foo_id])
references LINKEDSERVER.RemoteDatabase.dbo.tbl_bar ([id])
次に、次のエラーが発生します。
オブジェクト名'LINKEDSERVER.RemoteDatabase.dbo.tbl_bar'に、最大数を超えるプレフィックスが含まれています。最大は2です。
同じ効果を得る方法はありますか?