开发者

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 qualify开发者_运维百科ing 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.


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜