Index on view

  • I required to implement to set index on view in order to improve the performance.

    plese help me with syntax.

    I am getting the following message when i tried the same.

    Msg 1939, Level 16, State 1, Line 2

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

  • Create the view using the "WITH SCHEMABINDING" option.

  • Thanks a lot Michael.But problem still exists for my case.I have created view for the table from other database instead of same database.So i need to write query like below.

    CREATE VIEW [dbo].[gemaEmployee] WITH SCHEMABINDING

    AS

    Begin

    Select column1, column2, column3 from NewDB.dbo.table1

    End

    In this scenario i am getting the following message

    Cannot schema bind view 'dbo.table1' because name NewDB.dbo.table1' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.

  • Create the view using "WITH SCHEMABINDING" in the other database.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply