Dec 30, 2013

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


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

When we will create an index on view

CREATE UNIQUE CLUSTERED INDEX CI_ViewStu
ON dbo.view_StuInfo(Age)

We may get error message like:
Cannot create index on view 'view_StuInfo' because the view is not schema bound.

Since we can create an index on only those view which are schema bind with base table. Scheama bind means we cannot change the schema of the base objects unless and unill we don't remove the schema binding view  or alter or drop the view.

Solution:

DROP VIEW view_StuInfo
CREATE VIEW view_StuInfo WITH SCHEMABINDING
AS
SELECT Age,Name FROM dbo.Student

Note: It is necessay to specify the schema name (dbo) in the object.

No comments:

Post a Comment