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 ..."
One example with the original code would be as follows:
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
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:
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
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).
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).
Any pointers in the right direction are appreciated, thank you.
Update
The actual error message is like:
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]"
G.