So in Part II of this article I had created a View so that I could then create an index on this view to see if that was going to give me the expected results. I did create the view, but not the index. So you probably already know. These columns are non-deterministic and as a result the create index statement fails.
Msg 1963, Level 16, State 1, Line 1
Cannot create index on view "TESTDATABASE.dbo.vDateSelection". The view contains a convert that is imprecise or non-deterministic.
So that ends the questions...for now about indexed views and the effect of the results.
So here comes the results of how this works with no changes to the actual syntax of the query. I will introduce them one a time and then we will take a deep dive into why this behavior works sometimes and not all. And if this is correct behavior, is there the possibility that something that is executed today could fail in the future.
So looking at the scripts from my previous post there are some obvious elements missing form the schema. How about a primary key on each of the tables...and lets make these clustered unique as well.
We can then also add the foreign key constraint for the ID. As you can see I have modified testTable1 by adding an Identity columns for my primary key.
With these changes we are close, Well I thought...but I am still getting the same error.
The results were the same.
So lets go the full distance now and add the index to the LookupTypeID Field to complete the cycle.
--Add Non Clustered Index.
And BAM. Still the same results. What could be going on here...In the article I will try to understand this myself as well as get some commentary from some insiders...