LucieLastic
Programmer
hi
I have the same table in two different schemas, one of them is acting like a static table and the other is used for test loads of the data we send to the client. The tables have a composite PK but I only really need to check the asset_id col but if I have to use both cols in the PK in the one constraint, that is ok too.
[schemaOne].TableA
PK asset_id varchar(18)
PK leg_num int
[schemaTwo].TableB ('static' table)
PK asset_id varchar(18)
PK leg_num int
I've tried the following but neither works:
I'd be grateful for any help to point me in the right direction.
Many thanks
Lou
I have the same table in two different schemas, one of them is acting like a static table and the other is used for test loads of the data we send to the client. The tables have a composite PK but I only really need to check the asset_id col but if I have to use both cols in the PK in the one constraint, that is ok too.
[schemaOne].TableA
PK asset_id varchar(18)
PK leg_num int
[schemaTwo].TableB ('static' table)
PK asset_id varchar(18)
PK leg_num int
I've tried the following but neither works:
Code:
ALTER TABLE [schemaOne].[TableA] WITH CHECK ADD
CONSTRAINT [FK_TableA] FOREIGN KEY([asset_id])
REFERENCES [schemaTwo].[TableB] ([asset_id])
GO
ALTER TABLE [schemaOne].[TableA] WITH CHECK ADD
CONSTRAINT [FK_TableA] FOREIGN KEY([asset_id],[leg_num])
REFERENCES [schemaTwo].[TableB] ([asset_id],[leg_num])
GO
I'd be grateful for any help to point me in the right direction.
Many thanks
Lou