3

Up till now I have been working directly on SQL Server instances, and am now playing around with how best to keep databases in source control. The visual studio database project seems to be exactly what I want.

However, on trying to build a fairly small database I get several hundred SQL71561 errors. The code is this:

CREATE VIEW [dbo].[View Name] AS
SELECT
    EA.colName,
    ...
FROM
    DbName.dbo.TableName EA

And the error is this:

SQL71561: View: [dbo].[View name] 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:
[DbName].[dbo].[TableName].[colName] or [DbName].[dbo].[TableName].[EA]::[colName].

If I add an AS to the table alias, then the code seems to be accepted. It seems that column aliases are allowed to skip the 'AS' keyword.

  • What version of Visual Studio? – Max Vernon Aug 18 '17 at 13:41
  • 1
    Visual-Studio 2017 – Zach Smith Aug 18 '17 at 13:42
  • Visual Studio has quirks in General. Off the top of my head: When you're working on SSRS Reports in Visual Studio 2008: - All objects (tables, columns, schemas, databases) are wrapped in [brackets], which I assume is to compensate for Underlines/spaces. - Any Outer join gets re-written to (LEFT OUTER JOIN/FULL OUTER JOIN/etc.) It's just standard refactoring that takes place. – MguerraTorres Aug 18 '17 at 13:42
  • You have an errant comma in your column list. – Max Vernon Aug 18 '17 at 13:43
  • 1
    no. the database was imported from a sql server instance. and the query works on that instance – Zach Smith Aug 18 '17 at 13:47
3

I think this is happening because you're qualifying the database name in the query.

So remove **DBName** form the select clause; Visual Studio would then accept it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.