Foreign keys can't be connected to non-local objects - they have to reference local tables. You get the "maximum number of prefixes" error because you're referencing the table with a 4-part name (LinkedServer.Database.Schema. Object), and a local object would only have a 3-part name Other solutions : Replicate the data from the source (the location of the view) to the same server as the table you're trying to add the key on.
You can do this hourly, daily, or whatever, depending on how often the source data changes Add a trigger on the source table to push any changes to your local copy. This would essentially be the same as #1, but with immediate population of changes Add an INSTEAD OF" trigger to your table that manually checks the foreign key constraint by selecting from the linked server and comparing the value you're trying to INSERT/UPDATE. If it doesn't match, you can reject the change.
Foreign keys can't be connected to non-local objects - they have to reference local tables. You get the "maximum number of prefixes" error because you're referencing the table with a 4-part name (LinkedServer.Database.Schema. Object), and a local object would only have a 3-part name.
Other solutions : Replicate the data from the source (the location of the view) to the same server as the table you're trying to add the key on. You can do this hourly, daily, or whatever, depending on how often the source data changes. Add a trigger on the source table to push any changes to your local copy.
This would essentially be the same as #1, but with immediate population of changes Add an INSTEAD OF" trigger to your table that manually checks the foreign key constraint by selecting from the linked server and comparing the value you're trying to INSERT/UPDATE. If it doesn't match, you can reject the change.
You can, but you have to use some dynamic SQL trickery to make it happen. Declare @cmd VARCHAR(4000) SET @cmd = 'Use YourDatabase ALTER TABLE YourTable DROP CONSTRAINT YourConstraint' exec YourServer.master.dbo. Sp_executesql @SQL.
No, foreign keys have to be made against user tables. Have you tried the below? Alter table baz with check add constraint fk1_baz_to_foo FOREIGN KEY(foo_id) references LINKEDSERVER.RemoteDatabase.dbo.
Tbl_bar(id) go.
Yes, that errors: "The object name 'LINKEDSERVER.RemoteDatabase.dbo. Tbl_bar' contains more than the maximum number of prefixes. The maximum is 2." – d4nt Jan 14 '09 at 13:36.
Foreign keys can't be connected to non-local objects - they have to reference local tables. You get the "maximum number of prefixes" error because you're referencing the table with a 4-part name (LinkedServer.Database.Schema. Object), and a local object would only have a 3-part name.
Replicate the data from the source (the location of the view) to the same server as the table you're trying to add the key on. You can do this hourly, daily, or whatever, depending on how often the source data changes. Add a trigger on the source table to push any changes to your local copy.
Add an INSTEAD OF" trigger to your table that manually checks the foreign key constraint by selecting from the linked server and comparing the value you're trying to INSERT/UPDATE. If it doesn't match, you can reject the change.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.