5

I am using DBCC CLONEDATABASE to create database copies without data. There are a number of databases that will not clone. The error message is:

Cannot insert duplicate key row in object 'sys.sysschobjs' with unique index 'clst'. The duplicate key value is (565577053).

It is always one of three IDs: 245575913, 565577053, 885578193. The three IDs will always be the object_id of a user defined table type in the database failing to clone. Most of my databases have user defined table types, however some will clone, others will not. In the model database, two of these IDs relate to the internal tables sys.plan_persist_context_settings & sys.plan_persist_query_hints. The third isn't matched in model.sys.objects.

I have seen other blogs mention dropping the objects in model. The model database doesn't have any user code and I was unable to drop those internal tables while logged in with DAC. The databases would have initially been created in SQL Server 2016 Std, the instance has been upgraded to 2019 Std CU17. The databases are restored to a sandbox server also 2019 Std CU17. This is where the clone fails. Prior to the upgrade (both production & sandbox were upgraded together), only 2 databases wouldn't clone, I now have 10!

Not sure if its relevant but the table type in sys.table_types is dbo.TableType, matching on type_table_object_id. in sys.objects it is sys.TT_TableType_34C8D9D1, is_ms_shipped set to 1. They are created as dbo.TableType.

Any help appreciated

1 Answer 1

4

(I've replaced my previous reply due to findings when reproing this.)

This fails for me as well. I don't have anything strange in my databases, so the issue seems to be with new stuff in the model database. This simple command fails for me:

DBCC CLONEDATABASE (AdventureworksDW, AdventureworksDW_Copy) 
WITH VERIFY_CLONEDB, BACKUP_CLONEDB;  

Msg 2601, Level 14, State 1, Line 13
Cannot insert duplicate key row in object 'sys.sysschobjs' with unique index 'clst'. The duplicate key value is (341576255).

SELECT OBJECT_NAME(341576255, DB_ID()) --None
SELECT OBJECT_NAME(341576255, DB_ID('model')) --'db_ledger_blocks'

So it seems to me that DBCC CLONEDATABASE is broken in 2022. I've mentioned this, we'll see if it is picked up in, say, a day. Else we should report this as a bug.

4
  • 2
    I passed this along internally, so we'll see. Dec 8, 2022 at 17:52
  • 2
    Engineering is working on a fix. Look at the release notes of CU1 when it comes out to see if the fix made it in. Dec 20, 2022 at 23:41
  • @DavidBrowne-Microsoft is here any update on when this will be fixed? We've run into it at my work
    – MarkJ
    Jul 17 at 10:50
  • This work fine for me now. I can't say which CU that fixed it, though. Jul 17 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.