Azure Data Studio unresolved references in referenced object not suppressed - sql-server

Using Azure Data Studio, I have created a project from an existing SQL Server database - [Main_project]
Some views in that database reference objects in another database.
I have created a separate project containing the definitions for the directly referenced objects - [Ref_project].
I added this as a 'database reference' to [Main_project], and selected 'suppress errors causes by unresolved references in the reference object'
However, when I try to build [Main_project] I am seeing errors SQL71501 : '...contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous...'
These relate to underlying objects for the view in the referenced object - [Ref_project] - which I expected to be suppressed.
Is that not correct?
If not, how do I (/is it possible to) set up the database reference for objects referenced directly from [Main_project] without having to create projects/ items for all subsequently referenced objects in other databases?

Related

Is there a way to use the actual database name as the Database Variable Name in a Referenced Database of a SQL Server Database Project?

It seems like when you add another database as a reference to a SQL Server Database Project, the way to reference that database in the query code is via the Database Variable Name which is the notation $(ReferencedDatabaseName):
So a query in the primary database would then reference an object from the referenced database in the following way:
SELECT Field1, Field2
FROM [$(ReferencedDatabaseName)].SchemaName.ObjectName
Is there a way to just directly reference the database by it's actual name, e.g.:
SELECT Field1, Field2
FROM ReferencedDatabaseName.SchemaName.ObjectName
If not, does that mean if I import an existing database that references objects in other databases into my solution, I need to replace all the referenced database names with this database variable name notation?
The literal database name could be used. The "Database variable" field has to be omitted when Database Reference is created.
There is a bug which causes Database Variable Name to be empty thereafter.
All you need to do is to reload solution.
Now the database can be referenced by it's actual name.
Yes, that is the only way, other than creating Synonyms for your referenced objects. Even in that case, you would still have to use the variable in the synonym.
If you are worried about a heavy lift of replacing all of the database names with variable references, do a ctrl+shift+h and replace all [database]. with [$(databasereference)].

PowerDesigner References symbols are auto-aligning when I don't want them to move

I'm using PowerDesigner 16.6. I have a Physical diagram with 26 tables but they are quite referenced between each other. First I have used an auto-align option but then I have changed some references layouts for a even better reading-ability.
Now when I want to add a new reference several of the lines are automatically changed. Is there a way how freeze/lock the references symbols?
Thank you

Query to get all unresolved reference tables fo all views in a database?

I want the get all the views along with its base tables/ objects which are missing their references as they got deleted while some operations. So, can anyone help me?

Cakephp bake error after schema change

I am trying to regenerate all scaffolding after a DB schema change, and getting exception SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db01.address_types' doesn't exist in [/.../vendor/cakephp/cakephp/src/Database/Schema/Collection.php, line 130]
address_types WAS previously a table, but has been changed to enum named address_type, so table is gone and it is even getting the pluralisation wrong! Where is cake/bake getting the old schema from ?
For future reference, the problem was that I had 'backed up' some old tables with a 'z.' prefix, to keep them (just in case), somehow these were still referenced, so once I removed them, those references were gone. Oops :)

SQL Server Indexed View syntax for joined DB

I'm trying to set up an index on a VIEW of mine.
First error was 1939, Schema Binding required.
Ok, no problem with that.
ALTER VIEW xyz WITH SCHEMABINDING AS abc
Now, in this VIEW I'm using one local table
[dbo].][ReleantTable] and two joined tables
from other databases on the same server:
OtherDbName..OtherRelevantTable
Altering the VIEW fails, stating OtherDbName..OtherRelevantTable
is invalid for schema binding.
I guess it's just an syntax issue. Could anyone get me hint
how to address my OtherDb?
In order to create an indexed view your base tables must reside within the same database.
Consult the following Microsoft Books Online reference for further details:
http://msdn.microsoft.com/en-us/library/ms191432(SQL.90).aspx

Resources