Sample Header Ad - 728x90

DBCC CLONEDATABASE returns error: Cannot insert duplicate key row in object 'sys.syssingleobjrefs

2 votes
1 answer
2000 views
I'm trying to run the following line of code:
CLONEDATABASE ([DBName],[DBName_Staging]) WITH VERIFY_CLONEDB
And I'm getting the following error: `Msg 2601, Level 14, State 1, Line 15 Cannot insert duplicate key row in object 'sys.syssingleobjrefs' with unique index 'clst'. The duplicate key value is (5, 51, 0).` I'm running on **Microsoft SQL Server 2016 (SP3) (KB5003279) - 13.0.6300.2 (X64)** From what I've read a possible solution is deleting the duplicate row from *model*. I know how to do it, I'm just not sure if it's safe, or if this is the best solution. Any suggestions? ---------------------------- Based the query in this sqlskills article the "duplicate" objects in model are objects like queue_messages_99999999, syscommittab, filestream_tombstone_99999999, etc. I am trying to create copies of 30+ databases so moving/removing the objects in the user database side is complicated at best. Is it safe to remove these *system* objects?
Asked by Kenneth Fisher (24317 rep)
Jul 27, 2022, 10:31 PM
Last activity: Jul 28, 2022, 02:33 PM