2

I am trying to add a view to a Sql Server Database Project in VS 2015. The view references two tables, which are NOT defined in the project. So, my view DDL looks like this:

CREATE VIEW [dbo].[My_View]
    AS select a.Name, b.Name
from [dbo].[TableA] a
join [dbo].[TableB] b
 on a.Ref = b.Ref

Neither TableA, nor TableB exists in the Database project, but they both exist in the target database. I don't want to add them to the project, because they belong to different application and should not be controlled by this particular project as it only defines a subset of tables/views in the target database. I can't compile my project because of the error: Error: SQL71501: View: [dbo].[My_View] has an unresolved reference to object [dbo].[TableA]. (And some further errors from the same root cause)

I tried adding a reference to master db - no luck.

Is there any way to circumvent this error? Or maybe somehow add a reference to the TableA and TableB to the project without actual DDL defining these tables?

Volma
  • 1,305
  • 9
  • 17
  • how do you expect to resolve the references later ? – McNets Jun 05 '17 at 10:02
  • @McNets - I am confident that TableA and TableB are always in the target database - there is another script that controls that (not VS Sql server project). – Volma Jun 05 '17 at 10:06
  • I believe the solution is to: 1. Create a separate database project "A", containing these tables; 2. Create a reference to this in your project. 3. Never deploy or change project A, just use it as a "stub" – Nick.Mc Oct 30 '20 at 00:38

0 Answers0