I have the following objects used in the following format in a view view instruction.
dbo.objects1 A INNER JOIN db2.dbo.object2 INNER JOIN db2.dbo.object3 INNER JOIN db2.dbo.object4 INNER JOIN db2.dbo.object5
objects1 is a table from Database1 that has indexes. objects2 through objects5 are in another database , and all 4 of these objects look like No indexes .
Now I am trying to create an indexed view with all these five objects, but the SQL server does not allow me.
First mistake:
Names must be in two-part format and an object cannot reference itself.
Second error:
Cannot schema bind view 'dbo.vw_Order' because name 'db2.dbo.object2' is invalid for schema binding.
Now I was looking for these errors, and I came to the following assumptions:
- Views cannot contain objects from multiple databases in a connection request.
- To create indexes in a view, all objects in the view must either have indexes or be bound to a schema (for example, functions).
When I run the view as a query, itβs recommended in the execution plan to create an index for columns from objects in db2. Please let me know if my assumptions are true. If not, let me know how I can create a view in this situation.
sql tsql sql-server-2008 sql-server-2012
Sanket j
source share