Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2010 Database Project - SQL03006 Error

I created a new SQL Server Database Project within VS 2010, imported the database objects and settings from a local database named "managers", and received the following error while attempting to build the project:

SQL03006: View: [dbo].[vw_mlFunds] has an unresolved reference to object [managers].[dbo].[mlfunds].

I don't know why this view is fully qualifying a table reference to include the actual database name and I would prefer not to have to change the sql, as it someone else's code and it technically is not incorrect. But I am thinking that fully qualifying the table name to include the name of the database is confusing the VS compiler, since it is expecting [dbo].[mlfunds], not [managers].[dbo].[mlfunds]. How best to resolve this issue? Can I set up a new database name variable/alias somewhere? Or will I have to refactor/modify the sql to get it to compile? Thanks in advance.

like image 978
Mary Hamlin Avatar asked Aug 23 '10 19:08

Mary Hamlin


3 Answers

Actually, it looks like the code will have to be modified, as this is not supported. Answer found in this post:

Using local 3-part names in programmability objects

like image 123
Mary Hamlin Avatar answered Oct 20 '22 21:10

Mary Hamlin


I was getting the same error after creating a project and importing a DB. The issue for me was that the FROM table reference included the fully qualified name, but the selected fields did not; as follows

SELEC l.UserID, l.Email, m.DOB, ...
FROM ***[DBName].dbo***.Layout as l
LEFT OUTER JOIN masterUs as m

I modified the fully qualified reference by removing the DBName and DBO portion and all errors were resolved

SELECT l.UserID, l.Email, m.DOB, ....
FROM Layout as l
LEFT OUTER JOIN masterUs as m
like image 38
David Avatar answered Oct 20 '22 22:10

David


You need to create another database project for the [managers] database and have your project 'reference' the other project. You can do this as a simple reverse-engineer step on the [managers] database that will import all the objects in that database into a new VSDB project. See Using References in Database Projects.

like image 1
Remus Rusanu Avatar answered Oct 20 '22 22:10

Remus Rusanu