unresolved reference to object [INFORMATION_SCHEMA].[TABLES]
Add a database reference to master
:
- Under the project, right-click References.
- Select Add database reference....
- Select System database.
- Ensure master is selected.
- Press OK.
Note that it might take a while for VS to update.
SSDT has an unresolved reference to object for views but works fine for procedure
After testing and trying different settings, I can conclude that the "correct" approach is to use the [$(RPTDK)] syntax, where the RPTDK is the name that of the parameter, as it is set when one adds the database reference to begin with.
select BILLINGITEM_ID,
TIMESTAMP,
BILLINGITEMTYPE_ENUMID,
VATCODE_ENUMID,
LCOMPANY_ID,
LEASESERVICECOMPONENT_ID
from [$(RPTDK)].[dbo].BILLINGITEM as bilitm
It is a bit annoying, and the code is now dependent on a SQLCMD mode parameter to work, when you want to copy and paste into a SSMS window.
Thanks Alfin for the assistance.
ps
The reason why this is not failing in a stored proc, is that it seems to be that Visual Studio SSDT is not checking for referenced objects in a stored proc, but does it for views. I tried to remove the reference all togetger, and the stored proc code still managed to build succesfully.
Warning SQL71502 - Procedure name has an unresolved reference to object name
This can be resolved by adding a database reference to the master database.
- Add Database Reference:
- Select the
master
database and click OK:
- Result:
VS 2012 Database Project unresolved reference to object Error
I solved this issue.
It seems a few of my views/SPs have referenced the tables using this naming convention ( 3 parts qualified name ):
DatabaseName.SchemaName.TableName
I changed all references to be as the following:
SchemaName.TableName
Related Topics
How to Extract Group from Regular Expression in Oracle
SQL Query Distinct with Row_Number
Seeing the Underlying SQL in the Spring Jdbctemplate
How to Include Null Values in a Min or Max
Dynamic SQL to Generate Column Names
Google Spreadsheet "=Query" Join() Equivalent Function
Using Excel Vba to Run SQL Query
Using Pivot on Multiple Columns of an Oracle Row
Execute Immediate Within a Stored Procedure Keeps Giving Insufficient Priviliges Error
SQL Query to Find Nth Highest Salary from a Salary Table
Ms SQL "On Delete Cascade" Multiple Foreign Keys Pointing to the Same Table
Postgresql Sequence Based on Another Column
SQL to Entity Framework Count Group-By