【发布时间】:2015-05-15 22:37:35
【问题描述】:
遇到一个奇怪的问题。假设在一个空的解决方案 Bart 和 Homer 中有两个数据库项目。 Bart 已添加为 Homer 的数据库引用。
Bart 项目定义了一个函数:
CREATE FUNCTION [dbo].[Message]()
RETURNS NVARCHAR(255)
AS
BEGIN
RETURN 'I am a value returned from another database'
END
然后 Homer 项目定义了一个表:
CREATE TABLE [dbo].[Messages]
(
[Id] INT NOT NULL PRIMARY KEY
)
还有一个观点:
CREATE VIEW [dbo].[MessagesV]
AS SELECT Id, Bart.dbo.Message() AS [Message]
FROM dbo.Messages
尝试构建时,出现以下错误:
Error 2 SQL71501: Computed Column: [dbo].[MessagesV].[Message]
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: [Bart].[dbo].[Message] or
[dbo].[Messages].[Bart]::[dbo].[Message].
Error 1 SQL71501: View: [dbo].[MessagesV] 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:
[Bart].[dbo].[Message] or [dbo].[Messages].[Bart]::[dbo].[Message].
我应该如何在视图中正确引用 Bart UDF?
【问题讨论】: