不能在具有唯一索引 'si_xdes_id' 的對(duì)象 'sys.syscommittab' 中插入重復(fù)鍵的行由于錯(cuò)誤 2601,無(wú)法將該提交表刷新到 DBID 7 中的磁盤(pán)
廣告:
sys.syscommittab
IT IT = 內(nèi)部表
S = 系統(tǒng)表
INTERNAL_TABLE
消息 2601,級(jí)別 14,狀態(tài) 1,過(guò)程 sp_flush_commit_table,行 15 [批起始行 0]
不能在具有唯一索引 'si_xdes_id' 的對(duì)象 'sys.syscommittab' 中插入重復(fù)鍵的行。
語(yǔ)句已終止。
消息 2601,級(jí)別 14,狀態(tài) 1,過(guò)程 sp_flush_commit_table,行 15 [批起始行 0]
不能在具有唯一索引 'si_xdes_id' 的對(duì)象 'sys.syscommittab' 中插入重復(fù)鍵的行。
消息 3999,級(jí)別 17,狀態(tài) 1,第 1 行
由于錯(cuò)誤 2601,無(wú)法將該提交表刷新到 DBID 7 中的磁盤(pán)。有關(guān)詳細(xì)信息,請(qǐng)查看錯(cuò)誤日志。
參照:
https://learn.microsoft.com/zh-cn/troubleshoot/sql/database-engine/replication/duplicate-keys-sys-syscommittab-table#transact-sql-script
單用戶啟動(dòng)sqlserver
當(dāng) SQL Server 以單用戶模式啟動(dòng)時(shí),它將跳過(guò)屬于 AlwaysOn 可用性組(AG)的數(shù)據(jù)庫(kù)的啟動(dòng)過(guò)程。 如果需要排查需要以單用戶模式啟動(dòng) SQL Server 的更改跟蹤問(wèn)題,并且啟用了更改跟蹤的數(shù)據(jù)庫(kù)也是 AG 的一部分,則必須在單用戶模式下啟動(dòng) SQL Server 之前從 AG 中刪除數(shù)據(jù)庫(kù),以便數(shù)據(jù)庫(kù)聯(lián)機(jī)
net start mssql$SQL2008 /m --如果提示拒絕訪問(wèn) ,cmd請(qǐng)以管理員模式打開(kāi)
或者
net start mssqlsqlserver /m
或者
下面的示例在單用戶模式下啟動(dòng) SQL Server 實(shí)例,并且只允許通過(guò) SQL Server Management Studio 查詢編輯器進(jìn)行連接。
net start "SQL Server (MSSQLSERVER)" /m"Microsoft SQL Server Management Studio - Query"
例如:
net start mssql$SQL2008 /m
sqlcmd使用命令行連接到專(zhuān)用管理員連接 (DAC) 下的 SQL Server,并執(zhí)行修改后的 Transact-SQL 腳本。 例如:
sqlcmd -S PRODSERV1\MSSQLSERVER -A -E -i c:\temp\remove_duplicates.sql
或者
sqlcmd -S .\sql2008 -A -E -i K:\temp\20250326\sql.sql
--以下內(nèi)容保存為sql.sql
--Create a temporary database to store the necessary rows required to remove the duplicate data USE master GO IF EXISTS(SELECT 1 FROM sys.databases WHERE name = 'dbChangeTrackingMetadata') BEGIN DROP DATABASE dbChangeTrackingMetadata END GO CREATE DATABASE dbChangeTrackingMetadata GO --Table to store the contents of the SYSCOMMITTABLE USE dbChangeTrackingMetadata GO CREATE TABLE dbo.t_SYSCOMMITTABLE ( commit_ts BIGINT ,xdes_id BIGINT ,commit_lbn BIGINT ,commit_csn BIGINT ,commit_time DATETIME ) GO --Table to store the duplicate rows to be removed from the sys.syscommittab table CREATE TABLE dbo.t_syscommittab ( commit_ts BIGINT ,xdes_id BIGINT ,commit_lbn BIGINT ,commit_csn BIGINT ,commit_time DATETIME ,dbfragid INT ) GO --Enable the usage of OPENROWSET EXEC sys.sp_setbuildresource 1 GO --Change <AFFECTED_DB> to the database that contains the duplicate values USE MVC_Web GO DECLARE @rowcount BIGINT SET @rowcount = 0 --Copy all rows from the SYSCOMMITTABLE INTo the temporary database INSERT INTO dbChangeTrackingMetadata.dbo.t_SYSCOMMITTABLE SELECT commit_ts, xdes_id, commit_lbn, commit_csn, commit_time FROM OPENROWSET (table SYSCOMMITTABLE, db_id (), 0, 0) --Save the duplicate values INTo the temporary database INSERT INTO dbChangeTrackingMetadata.dbo.t_syscommittab SELECT ondisk_ct.* FROM sys.syscommittab as ondisk_ct JOIN dbChangeTrackingMetadata.dbo.t_SYSCOMMITTABLE as inmem_ct ON ondisk_ct.xdes_id = inmem_ct.xdes_id --Delete the duplicate values DELETE FROM sys.syscommittab WHERE xdes_id in ( SELECT xdes_id from dbChangeTrackingMetadata.dbo.t_syscommittab ) SET @rowcount = @@rowcount IF (@rowcount > 0) BEGIN PRINT '' PRINT 'DELETED '+CAST(@rowcount as NVARCHAR(10))+' rows from sys.syscommittab that were also stored in SYSCOMMITTABLE' PRINT '' END ELSE BEGIN PRINT '' PRINT 'Failed to DELETE DUP rows from sys.syscommittab' PRINT '' END EXEC sys.sp_setbuildresource 0 GO
廣告: