I use SQL Server 2008 R2.
In my database exists multi indexed view and multi view that use of these indexed view with hint NOEXPAND. When I get script of my database by SSMS (Database\Tasks\Generate Script … ), SSMS product script by below order :
- script of indexed view
- script of view that use of above indexed view
- script of clustered indexed of indexed view.
When I run created script, SQL server create first indexed view with no clustered index, then want to create view of indexed view with NOEXPAND hint, that cause raise error.
What I do?
SSMS error : hint 'noexpand' on object ..(indexed view).. is invalid.
I Search for my question and find method to solve this problem.
this problem appear when you create a simple view named view1 then created another view named view2 then use view2 in view1 then alter view2 to indexed view.
for solve this problem , you must recreate view1.