Hello, Carlos.
As there is no SQL Server Spanish Edition Forum, I'll translate your question this time.
Como no hay foro de SQL Server en Español, traduciré tu pregunta esta vez. Trata de ponerla en inglés la próxima, o intenta en el foro de VFP en español.
I need to create an external key reference between databases. For example, I need to relate the vendors table of the Sistema database with the orders table in the Inventory database:
ALTER TABLE ordenes ADD CONSTRAINT FK_proveedores_ordenes FOREIGN KEY (prove_uq) REFERENCES sistema.dbo.proveedores(unico)
But that generates an error: "Cross-reference of external keys between databases not supported".
Could you give me some tip? Tables are in different databases because Sistema has common tables for the other databases, for example, vendors table is common to Inventory_Company_A, Inventory_Company_B, Accounting_Company_A, Accounting_Company_B, etc. And I need to keep integrity. I can't delete a vendor involved in a transaction in any of the other databases.
Thanks for your help.
My own advice would be to change the way in which you're dealing with this. I'd put everything in a single database, and instead of having different databases for every company running the same application, I'd put a Company field in every table that isn't common.
Mi propio consejo es que cambies la forma en que está manejando todo esto. Yo pondría todo en una sola base de datos, y en lugar de tener una por cada empresa usando la misma aplicación, pondría un campo empresa en cada tabla que no sea común. De hecho, es lo que hago en mis aplicaciones.Regards,