A few days ago, I wrote a blog about an error while creating a clone of a database using DBCC CLONEDATABASE command. Here is the link to read that blog. SQL SERVER – DBCC CLONEDATABASE Error: Cannot Insert Duplicate Key Row In Object ‘sys.sysschobjs’ With Unique Index ‘clst’.
Here is another error received by me while running DBCC CLONEDATABASE. The message looks very similar but different system table.
Database cloning for ‘SQLAUTH’ has started with target as ‘SQLAUTH_CLONE’.
Msg 2601, Level 14, State 1, Line 1
Cannot insert duplicate key row in object ‘sys.sysowners’ with unique index ‘nc1’. The duplicate key value is (Domain\DBReader).
WORKAROUND/SOLUTION for CLONEDATABASE
Since it was appearing again, I started reading more about it and documentation from Microsoft says below:
DBCC CLONEDATABASE doesn’t support the creation of a clone if there are any user objects (tables, indexes, schemas, roles, and so on) that were created in the model database. If user objects are present in the model database, the database clone fails with the following error message:
Msg 2601, Level 14, State 1, Line 1
Cannot insert duplicate key row in object with unique index ‘index name’. The duplicate key value is
That makes perfect sense. As per documentation, I need to drop the object from the model database. As per error message which I received, it was due to a user in the model database. Once I dropped user, it went fine.
Here are a few related blog posts which you may find interesting:
- Impact of CHECKPOINT On Memory – SQL in Sixty Seconds #084
- SQL Server Performance Tuning Practical Workshop – Discovery Phase – Online Training
- SQL Server Performance Tuning Practical Workshop – Discovery Phase – In Person Training
- What is Faster, SUM or COUNT? – Interview Question of the Week #231
- SQL SERVER – Automatic Seeding of Availability Database ‘SQLAGDB’ in Availability Group ‘AG’ Failed With a Transient Error. The Operation Will be Retried
- SQL SERVER – Add Database to Availability Group Failure – This BACKUP or RESTORE Command is Not Supported on a Database Mirror or Secondary Replica
Reference: Pinal Dave (https://blog.sqlauthority.com)
First appeared on SQL SERVER – DBCC CLONEDATABASE Error – Msg 2601: Cannot Insert Duplicate Key Row in Object ‘sys.sysowners’ With Unique Index ‘nc1’.