I have a database project in SSDT and when I import a view that references objects in a different database, I get error SQL71561, with a description along these lines:
Error 4 SQL71561: View: [schema].[viewname] has an unresolved reference to object [other_db].[schema].[table].[column]
I spent some time trying to figure this out, so to help others running into this I will post the answer that worked for me.
My problem was from a view. In the view I had...
...FROM [MyDatabase].[dbo].[MyTable]
I replaced it with...
...FROM [MyTable]
The reason is that you may be importing the bacpac/dacpac into a different database name so the reference to [MyDatabase] might not be valid.
To resolve this, I added a reference to the other database, clearing out the "Database variable" field in the dialog. If I didn't clear this field, when doing a schema compare, SSDT would generate the update script using the database variable name, which would fail.
Look at the "Example usage" text and verify that it looks as expected. Click "OK" to add the reference and that should take care of the 'unresolved reference' errors.
After doing this, I was able to do a schema comparison, but trying to build the project produced the following error:
Error 408 SQL00208: Invalid object name 'db.schema.table'.
Going to the project properties and unchecking "Enable extended Transact-SQL verification for common objects" allowed the project to build successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With