0

Hi All,

I have a SQL database which has many views and needs indexing. Unfortunately SQL server does not let me add indexes with schema bind error. There are app. 50 views created on the database and I don't want to delete and re-create them one by one.

Is there an easier way to convert regular views to schemabind views to save time and effort?

Many thanks
telmessos

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by BitBlt
0

Alas, there is not. However, you can use SSMS to generate the alter statements and then add the "WITH SCHEMABINDING" attribute fairly quickly. As long as there's no change to the structure of the view, you should be pretty safe.

Just a few caveats though:
1. Once you do schema binding, you can't drop the underlying table(s), or alter them in a way that will affect the view definition. See MSSQL Books OnLine "ALTER VIEW" for more information.
2. The first index you put on a schema-bound view MUST BE a unique clustered index. Subsequent indices don't need to be.
3. All the referenced tables have to be in the same database.

Sorry there's not better news...good luck!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.