title: SQL03006 error in VS2010 Database Project (SQL Server 2008)
body: <p>When I try to set up a database project for SQL Server 2008 in VS2010 I keep running into error "SQL03006 - Column xyz contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects ..."</p>
  
  <p>One example with the original code would be as follows:</p>
  
  <pre><code>CREATE VIEW [dbo].[vwSomeView]
  AS
  SELECT 
      CT.ID, 
      CT.UserName, 
      ST.Title
  FROM
      SomeOtherDatabase.dbo.ComputerTable CT
  JOIN
      SomeOtherDatabase.dbo.SoftwareTable ST ON
      CT.ID = ST.ComputerID
  </code></pre>
  
  <p>Now the error only refers to e.g. column CT.UserName, not CT.ID. I also added a corresponding database reference to "SomeOtherDatabase" and updated the code as recommended by several posts I found during my search for a solution:</p>
  
  <pre><code>CREATE VIEW [dbo].[vwSomeView]
  AS
  SELECT 
      CT.ID, 
      CT.UserName, 
      ST.Title
  FROM
      [$(SomeOtherDatabaseName)].dbo.ComputerTable CT
  JOIN
      [$(SomeOtherDatabaseName)].dbo.SoftwareTable ST ON
      CT.ID = ST.ComputerID
  </code></pre>
  
  <p>What I don't understand is why there is a problem with one column from the CT table, but not the other. When I look at the table definition in the database project, all seems to be fine as the column is there (as expected).</p>
  
  <p>I'm also not quite sure whether I can refer to the table names by their alias once that is defined, i.e. do I have a problem writing "CT.ComputerID" instead of "[$(SomeOtherDatabaseName)].dbo.ComputerTable" (I don't think so, but I keep running into so many errors that I feel a little bit lost at the moment).</p>
  
  <p>Any pointers in the right direction are appreciated, thank you.</p>
  
  <p><strong>Update</strong></p>
  
  <p>The actual error message is like:</p>
  
  <pre><code>SQL03006: View: [dbo].[vwSomeView] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [$(SomeOtherDatabaseName)].[dbo].[ComputerTable]::[ID] or [$(SomeOtherDatabaseName)].[dbo].[SoftwareTable]::[ID]"
  </code></pre>
  
  <p>G.</p>