Visual Studio 2010 数据库项目:参考外部数据库

发布于 2024-12-03 06:07:12 字数 1530 浏览 1 评论 0 原文

我通过从现有数据库导入架构来创建一个数据库项目。在项目中,我正在创建将数据与另一个数据库合并的存储过程...我的问题是,我收到了大量关于引用数据库中的数据的警告。下面我将包括屏幕截图和有问题的过程

存储过程

CREATE PROCEDURE [dbo].[GetContact]
    @ContactID [int]
AS
BEGIN

    SET NOCOUNT ON;

    SELECT 
        FirstName = COALESCE(a.FirstName, b.first_name),
        LastName = COALESCE(a.LastName, b.last_name),
        Organization = COALESCE(a.Organization, b.company),
        LanguageTypeID = COALESCE(a.LanguageTypeID, (CASE WHEN b.default_language = 'Spanish' THEN 3 ELSE 2 END))
    FROM [dbo].[Contact] AS a
    FULL OUTER JOIN [OldDB].[dbo].[contacts] AS b
    ON a.ContactID = b.contact_identification_number
    WHERE a.ContactID = @ContactID

END

Visual Studio

架构资源管理器

在此处输入图像描述

错误列表

在此处输入图像描述

Warning 12  SQL04151: Procedure: [dbo].[GetContact] 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: [dbo].[Contact].[b]::[Default_Language], [*].[dbo].[Students].[b]::[Default_Language] or [*].[dbo].[Students].[Default_Language]. c:\users\*\documents\visual studio 2010\projects\TED\TED\Schema Objects\Schemas\dbo\Programmability\Stored Procedures\dbo.GetContact.proc.sql   21  52  TED

关于如何参考另一个人的任何想法模式来摆脱这些警告,以便我可以专注于真正的问题?

I created a Database project by importing a schema from an existing database. In the project I am creating stored procedures that merge data with another database... My issue is that I get a ton of Warnings on the data from the referenced database. Below I will include screenshots and the offending procedure

Stored Procedure

CREATE PROCEDURE [dbo].[GetContact]
    @ContactID [int]
AS
BEGIN

    SET NOCOUNT ON;

    SELECT 
        FirstName = COALESCE(a.FirstName, b.first_name),
        LastName = COALESCE(a.LastName, b.last_name),
        Organization = COALESCE(a.Organization, b.company),
        LanguageTypeID = COALESCE(a.LanguageTypeID, (CASE WHEN b.default_language = 'Spanish' THEN 3 ELSE 2 END))
    FROM [dbo].[Contact] AS a
    FULL OUTER JOIN [OldDB].[dbo].[contacts] AS b
    ON a.ContactID = b.contact_identification_number
    WHERE a.ContactID = @ContactID

END

Visual Studio

Schema Explorer

enter image description here

Error List

enter image description here

Warning 12  SQL04151: Procedure: [dbo].[GetContact] 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: [dbo].[Contact].[b]::[Default_Language], [*].[dbo].[Students].[b]::[Default_Language] or [*].[dbo].[Students].[Default_Language]. c:\users\*\documents\visual studio 2010\projects\TED\TED\Schema Objects\Schemas\dbo\Programmability\Stored Procedures\dbo.GetContact.proc.sql   21  52  TED

Any thoughts as to how I can reference another schema to get rid of these warnings so I can focus on real issues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哆兒滾 2024-12-10 06:07:12

您的数据库项目不知道您服务器的其他数据库,例如“OldDB”。您应该在项目属性中定义数据库交叉引用。
请参阅此处的说明:http://publicityson.blogspot。 com/2009/11/using-database-project-cross-database.html

Your database project doesn't know the the other databases of you server like "OldDB". You should define a Database Cross Reference in the Project Properties.
See the explanation here: http://publicityson.blogspot.com/2009/11/using-database-project-cross-database.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文