Visual Studio 2010数据库项目:引用外部数据库

时间:2011-09-08 01:28:16

标签: visual-studio-2010 database-schema

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

存储过程

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

架构资源管理器

enter image description here

错误列表

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

有关如何引用其他架构以摆脱这些警告的任何想法,以便我可以专注于实际问题吗?

1 个答案:

答案 0 :(得分:2)

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