首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 數據庫知識 >  >> SQL Server 資料庫 >> 關於SqlServer

Win2000 下附加資料庫失敗:字符集與排序規則不匹配的排查實錄

     編輯:關於SqlServer

錯誤現象

在中文 Win98 升級安裝的 Win2000 Server 上,以預設方式安裝英文版 SQL Server 7.0 後,執行 sp_attach_db 附加原有資料庫報錯:

Server: Msg 1816, Level 16, State 1
Could not attach the database because the character set, sort order, or Unicode collation for the database differs from this server.
Warning: sort order 52 in database differs from server sort order of 199.
Warning: Unicode language locale 1033 in database differs from server Unicode language locale of 2052.

原因分析

  • 資料庫建立時的字符集、排序規則、Unicode 定序與目前 SQL Server 實例不一致。
  • 英文版 SQL Server 預設安裝字符集為 ISO Character Set,排序為 Dictionary order, case-insensitive,Unicode 定序為 General。
  • 但若作業系統是從中文 Win98 升級而來,系統區域設定可能導致 SQL Server 實際運行的定序與預期不符。

解決過程

  1. 嘗試重裝 SQL Server 並手動指定字符集/排序規則,錯誤依舊。
  2. 懷疑作業系統層面差異,於一台「乾淨安裝」Win2000 的機器上重現步驟,附加成功。
  3. 回到問題機器,從 DOS 重新格式化並全新安裝 Win2000(不從 Win98 升級),再裝 SQL Server,問題解決。

核心結論

從中文 Windows 98 升級/安裝的 Windows 2000,其底層字符集/定序設定會與英文版 SQL Server 產生衝突,導致無法附加不同定序的資料庫。

建議

  • 生產環境盡量在乾淨安裝的作業系統上部署 SQL Server。
  • 若必須附加異定序資料庫,請在安裝 SQL Server 時嚴格匹配資料庫的字符集、排序規則與 Unicode 定序。
  • 避免跨語言版本作業系統升級後再安裝資料庫引擎。

此問題雖罕見,但對災難恢復場景極具參考價值。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved