我有一个看起来像这样的视图:
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
注意:HighLevelTestId 和 LowLevelTestId 保证永远不会有相同的值(没有冲突)。
我有另一个看起来像这样的表:
CREATE TABLE [Reference].[TestAddition](
[TestId] [BigInt] NOT NULL,
[OtherStuff] [bit] NOT NULL,
....
)
我真的很想将我的TestAddition
表添加到我Test
对 TestId 列的视图中(为了参照完整性和 OData 的易用性)。
有没有办法做到这一点?