I have a view that looks like this:
CREATE view reference.Test WITH SCHEMABINDING as SELECT reference.HighlevelTestId as TestId, Name, IsActive, cast(1 as bit) as IsHighLevelTest FROM reference.HighlevelTest UNION ALL SELECT LowLevelTestId as TestId, Name, IsActive, cast(0 as bit) as IsHighLevelTest FROM reference.LowLevelTest GO
NOTE: HighLevelTestId and LowLevelTestId are guaranteed to never have the same values (no conflicts).
I have another table that looks like this:
CREATE TABLE [Reference].[TestAddition]( [TestId] [BigInt] NOT NULL, [OtherStuff] [bit] NOT NULL, .... )
I would really like to FK my
TestAddition table to my
Test view on the TestId column (for referential integrity and ease of use with OData).
Is there any way to do that? (Any way to change my view to make this work?)