使用 SSDT,当我的视图引用不同数据库中的对象时,如何解决 SQL71561 错误? [英] Using SSDT, how do I resolve SQL71561 errors when I have a view that references objects in a different database?

查看:17
本文介绍了使用 SSDT,当我的视图引用不同数据库中的对象时,如何解决 SQL71561 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SSDT 中有一个数据库项目,当我导入引用不同数据库中的对象的视图时,我收到错误 SQL71561,并有以下几行描述:

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:

错误 4 SQL71561:视图:[schema].[viewname] 有一个未解析的引用对象 [other_db].[schema].[table].[column]

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.

推荐答案

为了解决这个问题,我添加了对另一个数据库的引用,清除了对话框中的数据库变量"字段.如果我没有清除这个字段,在进行模式比较时,SSDT 将使用数据库变量名称生成更新脚本,这将失败.

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. 向项目添加数据库引用.
  2. 就我而言,另一个数据库是同一解决方案中的另一个项目,因此我可以在添加数据库引用"对话框的第一个下拉列表中选择它.
  3. 确保数据库名称"字段中的文本正确.
  4. 清除数据库变量"字段.

查看示例用法"文本并验证它是否符合预期.单击确定"以添加引用,这应该处理未解析的引用"错误.

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:

错误 408 SQL00208:无效的对象名称db.schema.table".

Error 408 SQL00208: Invalid object name 'db.schema.table'.

转到项目属性并取消选中为常见对象启用扩展的 Transact-SQL 验证"允许项目成功构建.

Going to the project properties and unchecking "Enable extended Transact-SQL verification for common objects" allowed the project to build successfully.

这篇关于使用 SSDT,当我的视图引用不同数据库中的对象时,如何解决 SQL71561 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆