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