摘要:本文主要介紹我在將一個(gè)本地?cái)?shù)據(jù)遷移到SQL Azure數(shù)據(jù)庫(kù)時(shí),遇到的一個(gè)錯(cuò)誤信息“Deprecated feature 'More than two-part column name' is not supported in this version of SQL Server.” (“列名多于兩個(gè)組成部分”),及其解決辦法。
關(guān)鍵詞: SQL Azure, TSQL, SQL Server 2008
我在把本地?cái)?shù)據(jù)遷移到SQL Azure時(shí),執(zhí)行如下腳本時(shí):
CREATE VIEW [dbo].[V_UserName]
AS
SELECT dbo.[User].Email FROM dbo.[User]
GO
出現(xiàn)錯(cuò)誤信息:
Msg 40512, Level 16, State 1, Procedure V_UserName, Line 3
Deprecated feature 'More than two-part column name' is not supported in this version of SQL Server.
這個(gè)錯(cuò)誤信息是由于在SELECT語句中列名dbo.[User].Email 由多于兩個(gè)部分組成。在MSDN的相關(guān)文檔(中文版:http://msdn.microsoft.com/zh-cn/library/ms143729.aspx, 英文版:http://msdn.microsoft.com/en-us/library/ms143729.aspx)中,有這個(gè)說明:在SQL Server 2008里支持 ,但是在SQL Server 2008之后的版本(具體哪一版本尚未確定)不再支持的功能列表里,包含這個(gè)功能,SELECT語句中的列名標(biāo)準(zhǔn)格式應(yīng)該是由兩部分組成,不支持三個(gè)部分或者四個(gè)部分組成的列名。通過這個(gè)例子,我們可以知道這個(gè)功能在SQL Azure數(shù)據(jù)庫(kù)已經(jīng)不再被支持。
解決辦法:我們可以去掉服務(wù)器名dbo, 執(zhí)行如下語句:
CREATE VIEW [dbo].[V_UserName]
AS
SELECT [User].Email FROM dbo.[User]
GO
【參考資料】
1. SQL Azure Notes, http://www.tewari.info/2009/09/10/sql-azure-notes/, 10 Sep, 2009
2. Deprecated Database Engine Features in SQL Server 2008, http://msdn.microsoft.com/en-us/library/ms143729.aspx, MSDN
3. SQL Server 2008 中不推薦使用的數(shù)據(jù)庫(kù)引擎功能, http://msdn.microsoft.com/zh-cn/library/ms143729.aspx, MSDN