我们在同一个视图定义中有四个度量值,每个量度引用相同的度量描述查找表。我们的问题是我们想要对这个视图进行模式绑定和索引。我们尝试使用别名以及重复连接到查找表的同义词。我们仍然无法将索引放在视图上,因为这些是“自连接”,或者因为模式绑定对象或约束表达式中的同义词无效。任何帮助或建议表示赞赏。
ALTER VIEW [dbo].[VPLAN_SEG_SYNtst] WITH SCHEMA BINDING
AS
SELECT DBO.PLAN_SEG.PLAN_SEG_ID, DBO.PLAN_SEG.PLAN_SEG_DESC,
DBO.PLAN_SEG.PLAN_ITEM_ID, DBO.SEG_SL_MEAS.SL_MEAS_DESC,
DBO.SEG_EST_SL_MEAS.SL_MEAS_DESC AS EST_SL_MEAS_DESC
FROM DBO.PLAN_SEG
INNER JOIN DBO.SEG_SL_MEAS
ON DBO.PLAN_SEG.CLIENT_ID = DBO.SEG_SL_MEAS.CLIENT_ID
AND DBO.PLAN_SEG.SEG_SL_MEAS_SYS_ID = DBO.SEG_SL_MEAS.SL_MEAS_SYS_ID
INNER JOIN DBO.SEG_EST_SL_MEAS
ON DBO.PLAN_SEG.SEG_EST_SL_MEAS_SYS_ID = DBO.SEG_EST_SL_MEAS.SL_MEAS_SYS_ID
AND DBO.PLAN_SEG.CLIENT_ID = DBO.SEG_EST_SL_MEAS.CLIENT_ID
GO
错误:
ERROR Msg 2788, Level 16, State 1, Procedure VPLAN_SEG_SYNtst, Line 5
Synonyms are invalid in a schemabound object or a constraint expression.
CREATE UNIQUE CLUSTERED INDEX idx_PLAN_SET_TST
ON VPLAN_SEG_TST (PLAN_SEG_ID)
ERROR Msg 1947, Level 16, State 1, Line 1 Cannot create index on view
"SLHUB.dbo.VPLAN_SEG_TST". The view contains a self join on "SLHUB.dbo.ZSL_MEAS".
答案 0 :(得分:0)
为了在视图上放置索引,它必须是模式绑定的。有关其他要求,请参阅http://msdn.microsoft.com/en-us/library/ms191432.aspx。