2013-06-29 106 views
3
Error 431 SQL71561: 
Computed Column: [dbo].[ViewAlertFrequency].[BeginDate] 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: 
[Lookup].[dbo].[AlertFrequency].[AlertFrequency]::[BeginDate] 
or [Lookup].[dbo].[AlertFrequency].[BeginDate] 

當前數據庫是Lookup,因此找到此對象時不應該有任何問題。這是從現有視圖導入的。看起來整個數據庫就是這樣。我不確定::語法是什麼。SQL71561錯誤 - 歧義參考

這裏是視圖:

CREATE VIEW [dbo].[ViewAlertFrequency] 

AS 

--### 
--ViewAlertFrequency 
--### 

--### 
--used by: eobResolve 
--### 

SELECT DISTINCT TOP 100 
    AlertFrequency.[ID]  AS [ID], 
    AlertFrequency.Code  AS Code, 
    AlertFrequency.[Name]  AS [Name], 
    AlertFrequency.[Description] AS [Description], 
    AlertFrequency.[Rank]  AS [Rank], 
    AlertFrequency.BeginDate AS BeginDate, 
    AlertFrequency.EndDate  AS EndDate 

FROM   
    Lookup.dbo.AlertFrequency AS AlertFrequency 

ORDER BY 
    AlertFrequency.[Rank]  ASC 


GO 
GRANT SELECT 
    ON OBJECT::[dbo].[ViewAlertFrequency] TO [eobResolve] 
    AS [dbo]; 
+1

你見過[this](http://blogs.msdn.com/b/bahill/archive/2009/08/26/using-self-referencing-or-local-3-part-names.aspx) ? –

+0

@IswantoSan我嘗試使用$(DatabaseName),但它仍然無法正常工作。我只是將3部分名稱更改爲2. –

+0

[VS 2012數據庫項目「未解決的對象引用」錯誤]的可能重複(http://stackoverflow.com/questions/13373310/vs-2012-database-project-unresolved -reference-to-object-error) –

回答

7

您使用3部分組成的命名約定在 「FROM」 子句。將「Lookup.dbo.AlertFrequency」更改爲「dbo.AlertFrequency」,您的問題應該消失。這與我有不同的結果。更改其中一個數據庫選項似乎足以解決這些三部分名稱,但我隨後遇到了有關跨數據庫引用(4部分名稱)的其他問題。我認爲只是將3部分名稱更改爲2部分[schema],[object]命名將是處理該問題的更簡單的方法。

GRANT語句只是指定將權限授予對象而不是模式。我不認爲它屬於對象定義,但我們在後期部署腳本中處理我們的權限,因爲它們從一個環境到另一個環境略有不同。

+0

你能解釋一下如何在數據庫選項中改變它嗎? –

+0

不確定你想要改變數據庫選項。如果您想忽略此警告,則可以修改項目屬性以忽略警告的數字部分(71561),如果嘗試忽略多個警告,則可以將它們作爲CSV列表輸入。 –