Cannot create index on view 'View_Table_Name' because the view is not schema bound

前端 未结 2 1699
一整个雨季
一整个雨季 2020-12-08 04:08

I am using Views in my stored Procedure(SQL-Server). For Improving Performance, I have tried to created INDEX of that View.

SET ANSI_NULLS ON
GO
SET QUOTED_I         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 04:20

    There are a number of restrictions on indexed views: no subqueries, no unions, no outer joins, etc. See this article for more details. But for your case, you simply need to create the view with schema binding.

    CREATE VIEW VW_Table_Name WITH SCHEMABINDING
    AS
    SELECT Col1,Col2,Col3 FROM Table_Name 
    GO
    

提交回复
热议问题