Unresolved Reference to Object [Information_Schema].[Tables]

unresolved reference to object [INFORMATION_SCHEMA].[TABLES]

Add a database reference to master:

  1. Under the project, right-click References.
  2. Select Add database reference....
  3. Select System database.
  4. Ensure master is selected.
  5. 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.

  1. Add Database Reference:

Add DB reference


  1. Select the master database and click OK:

Select database


  1. Result:

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



Leave a reply



Submit