title: Can you have a Foreign Key onto a View of a Linked Server table in SQLServer 2k5?
body: <p>I have a SQLServer with a linked server onto another database somewhere else. I have created a view on that linked server</p>
  
  <pre><code>create view vw_foo as
  select
  [id],
  [name]
  from LINKEDSERVER.RemoteDatabase.dbo.tbl_bar
  </code></pre>
  
  <p>I'd like to to the following</p>
  
  <pre><code>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
  </code></pre>
  
  <p>But that generates the error: "Foreign key 'fk1_baz_to_foo' references object 'dbo.vw_foo' which is not a user table."</p>
  
  <p>If I try and put the foreign key directly onto the table using the following</p>
  
  <pre><code>alter table [baz] with check 
  add constraint [fk1_baz_to_bar] 
    foreign key([foo_id]) 
    references LINKEDSERVER.RemoteDatabase.dbo.tbl_bar ([id])
  </code></pre>
  
  <p>Then I get the following error: </p>
  
  <blockquote>
    <p>The object name 'LINKEDSERVER.RemoteDatabase.dbo.tbl_bar' contains more than the maximum number of prefixes. The maximum is 2.</p>
  </blockquote>
  
  <p>Is there any way I can achieve the same effect?</p>