0

I have created a brand new database project in VS 2017. I have set the target platform to SQL Server 2016 and have added master and msdb as references.

The issue I am having is that I have a view that references sys.availability_groups and filters on the column is_distributed. It is throwing this error:

SQL71561: View: [dbo].[VUHL_vw_AGInfo] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [master].[sys].[availability_groups].[AG]::[is_distributed], [master].[sys].[availability_groups].[is_distributed], [master].[sys].[availability_replicas].[AG]::[is_distributed], [master].[sys].[dm_hadr_availability_group_states].[AG]::[is_distributed], [master].[sys].[dm_hadr_availability_replica_states].[AG]::[is_distributed] or [master].[sys].[dm_hadr_database_replica_states].[AG]::[is_distributed].

I know the column exists, and I know that it didn't used to exist prior to 2016 and I asked this question. However, even with that workaround it won't recognize the column.

Is there a way to get the database project to recognize the column, or to tell it not to care?

DForck42
  • 19,789
  • 13
  • 59
  • 84
  • From the error, it sounds like a column called `is_distributed` exists in more than one table that you're joining to. Try aliasing the tables in your joins, then prefacing each column in your `SELECT` list with the alias for the table you're getting it from. Should clear it right up. – Eric Brandt May 03 '19 at 15:02
  • @EricBrandt it is properly aliased – DForck42 May 03 '19 at 16:11

1 Answers1

0

I'm not 100% certain what I've done to get this working now, but it's now working.

Essentially, I closed and reopened VS and saw that somehow master and msdb were added twice as references. I removed all of those references, saved, and closed VS. I then reopened the project, added the references, and now it's working.

DForck42
  • 19,789
  • 13
  • 59
  • 84