Cannot drop the database 'SqlCloneTemp_cekvf232' because it is being used for replication
Hello,
I'm running the command below for multiple databases on the same server. It worked for more than 100 databases.
I don't understand why it works for all except for this one.
I'm not sure neither what is this database created automatically.
Regards,
Have a nice day and thank you
I'm running the command below for multiple databases on the same server. It worked for more than 100 databases.
I don't understand why it works for all except for this one.
I'm not sure neither what is this database created automatically.
New-SqlCloneImage -Name $NewImageName -SqlServerInstance $sqlServerInstance -DatabaseName $databasename -Destination $ImageDestination | Wait-SqlCloneOperation
2024-09-27 16:32:15.771 +02:00 [Information] Taking database "SqlCloneTemp_cekvf232" offline 2024-09-27 16:32:16.248 +02:00 [Information] Detaching database "SqlCloneTemp_cekvf232" 2024-09-27 16:32:16.250 +02:00 [Warning] Failed to detach database "SqlCloneTemp_cekvf232", falling back to hard detach Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot drop the database 'SqlCloneTemp_cekvf232' because it is being used for replication. at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at Microsoft.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader(Boolean isInternal, Boolean forDescribeParameterEncryption) at Microsoft.Data.SqlClient.SqlCommand.InternalEndExecuteNonQuery(IAsyncResult asyncResult, Boolean isInternal, String endMethod) at Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult) at Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location --- at Dapper.SqlMapper.ExecuteImplAsync(IDbConnection cnn, CommandDefinition command, Object param) in /_/Dapper/SqlMapper.Async.cs:line 670 at RedGate.SqlClone.Agent.Core.Sql.SqlDatabaseAttachmentDropper.Drop(CancellationToken ct) ClientConnectionId:6df2bba1-36bb-4465-a5b1-e9542685e35d Error Number:3724,State:1,Class:16
Best Answer
-
Eddie D Posts: 1,802 Rose Gold 5Hi ab12, thank you for your forum post.To reply to this comment:I'm not sure neither what is this database created automatically.SQL Clone when creating a SQL Clone Image from a backup file and /or applying data masking to an image, the process creates a temporary database to restore the backup file into.I suspect the issue reported here:2024-09-27 16:32:16.250 +02:00 [Warning] Failed to detach database "SqlCloneTemp_cekvf232", falling back to hard detachMicrosoft.Data.SqlClient.SqlException (0x80131904): Cannot drop the database 'SqlCloneTemp_cekvf232' because it is being used for replication.The source database is configured to use SQL Server Replication features. So when the process completes, SQL Clone cleans up to remove the temporary database and cannot due to the SQL Server Replication configured.
Sadly SQL Clone was never tested on databases using SQL Server Replication technology. I suspect that you will need to manually drop the temporary database created.
Many Thanks
Eddie