Cannot rename the table because it is published for replication

On this page

Updating a Devolutions Server data source with SQL Server Replication enabled returns the following error message:

Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot rename the table because it is published for replication.

Solution

  1. Run this SQL query and see if it returns 1038:

SELECT DatabaseVersion FROM dbo.DatabaseInfo
  1. If it does return 1038, then run this query:

if   exists (select * FROM dbo.DatabaseInfo where DatabaseVersion = 1038)

 AND exists (SELECT  1 FROM sys.indexes i INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id WHERE i.object_id = OBJECT_ID(N'dbo.LogMessage') AND i.name = 'PK_LogMessage' AND c.name = 'ID' AND type_desc = 'CLUSTERED')

BEGIN

	drop table dbo.LogMessage;

END

GO

if   exists (select * FROM dbo.DatabaseInfo where DatabaseVersion = 1038)

 AND exists (SELECT  1 FROM sys.indexes i INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id WHERE i.object_id = OBJECT_ID(N'dbo.LogMessage_Archive') AND i.name = 'PK_LogMessage_Archive' AND c.name = 'ID' AND type_desc = 'CLUSTERED')

BEGIN

	drop table dbo.LogMessage_Archive;

END

GO
  1. Start the data source update once again.

Devolutions Forum logo Give us Feedback