如果憑證式主體擁有用戶物件,SQL Server 升級會失敗
本文可協助您針對 SQL Server 累積更新 (CU) 或 Service Pack (SP) 報告執行資料庫升級腳本時的錯誤 574 的問題進行疑難解答。
徵兆
當您套用適用於 SQL Server 的 CU 或 SP 時,安裝程式會傳回下列錯誤訊息:
等候 Database Engine 復原控制代碼失敗。 請檢查 SQL Server 錯誤記錄檔以了解潛在原因。
此外,SQL Server 錯誤記錄檔中可能會記錄下列錯誤專案,以及錯誤 912 和 3417:
15136 The database principal is set as the execution context of one or more procedures, functions, or event notifications and cannot be dropped.
15138 The database principal owns a %S_MSG in the database, and cannot be dropped.
15141 The server principal owns one or more %S_MSG(s) and cannot be dropped.
15154 The database principal owns an %S_MSG and cannot be dropped.
15155 The server principal owns a %S_MSG and cannot be dropped.
15183 The database principal owns objects in the database and cannot be dropped.
15184 The database principal owns data types in the database and cannot be dropped.
15186 The server principal is set as the execution context of a trigger or event notification and cannot be dropped.
15284 The database principal has granted or denied permissions to objects in the database and cannot be dropped.
15421 The database principal owns a database role and cannot be dropped.
27226 The database principal has granted or denied permissions to catalog objects in the database and cannot be dropped.
33015 The database principal is referenced by a %S_MSG in the database, and cannot be dropped.
Error: 912, Severity: 21, State: 2.
Script level upgrade for database 'master' failed because upgrade step 'SSIS_hotfix_install.sql' encountered error 945, state 2, severity 25. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.
Error: 3417, Severity: 21, State: 3.
Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.
SQL Server shutdown has been initiated
原因
安裝 SQL Server 時,會從憑證建立包含在雙哈希標記 (###) 內的伺服器主體。 這些主體會被視為系統建立的主體。 它們不得對應至在或其他資料庫中擁有用戶對象 msdb
的資料庫主體。 當您嘗試升級 SQL Server 時,此預設組態的任何變更都可能會導致失敗。 這是因為升級腳本假設這些物件只有 SQL Server 所建立的相依性。
解決方法
使用 追蹤旗標 902 啟動 SQL Server。
若要判斷伺服器主體與資料庫主體的對應,請執行下列命令:
EXEC master.sys.sp_helplogins
將受影響對象的擁有權變更為不同的使用者。
重新啟動不含追蹤旗標的
902
SQL Server,讓升級腳本可以完成執行。
注意
雖然執行升級腳本失敗是「等候 資料庫引擎 復原處理失敗」錯誤的常見原因之一,但此問題也可能因為其他原因而發生。 錯誤表示更新安裝程式無法在安裝更新之後啟動服務或使其上線。 不論是哪一種情況,疑難解答都牽涉到檢閱錯誤記錄和安裝記錄,以判斷失敗的原因並採取適當的動作。