Click here to Skip to main content
13,904,914 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 21 Mar 2013
Licenced CPOL

Fixing SSDT Unresolved Reference to Object Error

, 21 Mar 2013
Rate this:
Please Sign up or sign in to vote.
Fixing the SSDT unresolved reference to object error

The SQL Server Data Tools (SSDT) for Visual Studio 2012 are a great set of tools for database development, but as any tool, they have some undesirable "features". One of those "features" is the "unresolved reference to object" error. The "unresolved reference to object" in a stored procedure is a warning, but for the function it is an error. The error fails the build and consequently the schema compare and update of the database.

The error normally is caused by a query that references an object on other database.

One example of the error is: Error 190 SQL71561: Function: [dbo].[myFunction] has an unresolved reference to object [myDatabase].[dbo].[Product].

In the example, the function [myFunction] is using the table [Product] from the database [myDatabase], that isn't the same database being managed by the database project of [myFunction].

A possible solution is to add a database reference to the database that has the missing object. The reference needs a Data-tier Application (dacpac file) that can be easily generated on the solution with the database project that has the missing object. Press the right mouse button over the database project and selected Snapshot Project. The dacpac file is created on the Snapshots folder. The file should then be copied to a common folder for re-usability.

In the project with the error, press the right mouse button over the References and selected Add Database Reference. The Add Database Reference dialog appears:

  1. Select the dacpac file.
  2. Select the database location. The most common option is "Different database, same server".
  3. Confirm that the Database name field is as expected.
  4. Clear the "Database variable" field in the dialog. If this field has a value, the queries must use this variable and not the database name.

Look at the "Example usage" text and verify that it looks as expected. Click "OK" to add the reference and that should take care of the 'unresolved reference' errors.

The database reference resolves the schema comparison issue, but trying to build the project produced the following error: Error 408 SQL00208: Invalid object name 'db.schema.table'.

To fix this error, go to the project properties and uncheck "Enable extended Transact-SQL verification for common objects".


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Rui Inacio
Team Leader
Portugal Portugal
I am an Experienced Senior Microsoft Consultant responsible for developing and defining architectures for various projects in a Microsoft environment, using a Service-Oriented Architecture (SOA) and web based applications.
I am also a project manager using agile methodologies and SCRUM.
Software Quality Assurance is a mandatory in every project I am responsible.
As someone said:
“Anyone can program, but not everyone is a programmer...”

You may also be interested in...

Comments and Discussions

QuestionNo "Enable extended Transact-SQL verification for common objects" on vs2015 pro Pin
Tony Dong21-Sep-16 12:50
memberTony Dong21-Sep-16 12:50 
GeneralMy vote of 5 Pin
Member 1275139920-Sep-16 22:05
memberMember 1275139920-Sep-16 22:05 
Question[My vote of 2] This would be helpful but VS won't let me snapshot the project until it Builds Pin
Member 1207062219-Oct-15 5:54
memberMember 1207062219-Oct-15 5:54 
QuestionI'm using visual studio 2013 and i don't see "Enable extended Transact-SQL verification for common objects" Pin
darius216-Oct-14 21:06
memberdarius216-Oct-14 21:06 
GeneralMy vote of 5 Pin
SPeacock7817-May-13 0:10
memberSPeacock7817-May-13 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190306.1 | Last Updated 21 Mar 2013
Article Copyright 2013 by Rui Inacio
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid