Using SSDT, how do I resolve SQL71561 errors when I have a view that references objects in a different database?

前端 未结 5 2330
我在风中等你
我在风中等你 2020-12-09 08:22

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:

5条回答
  •  不思量自难忘°
    2020-12-09 08:54

    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.

    1. Add a Database Reference to the project.
    2. In my case the other database was another project in the same solution, so I was able to select it in the first drop down on the "Add Database Reference" dialog.
    3. Make sure the text in the "Database name" field is correct.
    4. Clear out the "Database variable" field.

    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.

提交回复
热议问题