title: Creating Indexed View which references a Non Indexed View and objects from multiple DB's
body: <p>I have the following objects used in the following format in a create view statement.     </p>
  
  <pre><code>dbo.objects1 A
  INNER JOIN db2.dbo.object2 
  INNER JOIN db2.dbo.object3 
  INNER JOIN db2.dbo.object4
  INNER JOIN db2.dbo.object5
  </code></pre>
  
  <p>The <code>objects1</code> is a table from <code>Database1</code> which has Indexes. The <code>objects2 through objects5</code>  are in another <code>database</code> and all these 4 objects are view with <code>No indexes</code>. </p>
  
  <p>Now I am trying to create an indexed view with all the above five objects but SQL server is not allowing me. </p>
  
  <p>First error is:</p>
  
  <p><code>Names must be in two-part format and an object cannot reference itself.</code></p>
  
  <p>Second error is:</p>
  
  <p><code>Cannot schema bind view 'dbo.vw_Order' because name 'db2.dbo.object2' is invalid for schema binding.</code></p>
  
  <p>Now I googled these errors and I came to following assumptions:</p>
  
  <ol>
  <li>Views cannot contain objects from multiple databases in a join query.</li>
  <li>In order to create indexes on a view, all the objects in the view should have either indexes or should be schema binded (like Functions). </li>
  </ol>
  
  <p>When I run the view like a query, Execution Plan is recommending me to create an index on columns from objects in db2. Please let me know if my assumptions are correct. If not, please let me know a way as to how I can create a view in this situation. </p>