When you delete or modify a table, the following message is displayed: the table cannot be changed because it is being published for replication.

Source: Internet
Author: User
Tags sql server books

PRB: You receive error 3724 when you drop a non-replicated object
Http://support.microsoft.com /? Id = 326352

Symptoms
When you try to drop or to rename an object (a table, a view, or a stored procedure) that is not replicated, you may receive an error message that is similar to one of the following:
3724: cannot % s_msg the % s_msg '%. * ls 'because it is being used for replication.

15051: Cannot rename the table because it is published for replication.

Workaround
Important: The 3724 message may occur legitimately when an object is marked for replication. Do not use the following workaround if the object is being used for replication.

Steps to take before you work around this problem
1. Verify that no publications or subscriptions use the object as an article. You can check the sysarticles and sysmergearticles tables that are in your database to verify this.

For example, run the following queries against your database that contains the object that you want to drop: Select * From database_name .. sysarticles where name = 'object _ name'
Select * From database_name... sysmergearticles where name = 'object _ name'

If you see the object name in either query, do not use the following workaround. if you do not want the to use the database for replication, remove replication. whenever possible, remove replication by using SQL Server Enterprise Manager or by using scripts. for more information, see the "disabling publishing and distribution" topic in SQL Server books online. if you have no other options, try the workaround.
2. make sure that you did not enable this database for replication by using the sp_helpreplicationdboption system stored procedure. do not enable the database for replication. if it is enabled for replication, run the sp_removedbreplication stored procedure to disable replication.

Important: Running sp_removedbreplication on a database removes all replication objects from the database. therefore, all publications and subscriptions in the database are removed. only members of the SysAdmin fixed server role can run the sp_removedbreplication stored procedure. for more information about the sp_removedbreplication stored procedure, see the "sp_removedbreplication, transact-SQL reference" topic in SQL Server books online.

To run the sp_removedbreplication stored procedure, use the following code in which you replace dbname with the name of your database: sp_removedbreplication 'dbname'

 
3. make sure to have a contingency plan, such as a database backup. microsoft recommends that you take a full database backup of the database before you use the workaround. for more information about the BACKUP command, see the "backup, transact-SQL reference" topic in SQL Server books online.

Steps to work around und this behavior
After you make sure that you have considered all other potential options, mark all objects in the database as not used by Replication:

Notes: • The following procedure is dependent on SQL Server System tables. The structure of these tables may vary in different SQL Server versions. Microsoft does not recommend that you select directly from the system tables.
• In most cases, Microsoft does not recommend that you (or any user) change system tables directly. for example, do not try to modify system tables by using Delete, update, or insert statements, or by using user-defined triggers.
1. Run the following code. Replace object_name with the name of the object that you must modify: sp_configure 'Allow updates', 1
Go
Reconfigure with override
Go
Begin transaction
Update sysobjects set replinfo = 0 where name = 'object _ name'

 
2. Verify that only one row was affected. If the intended row in the sysobjects table was updated, commit the transaction, or roll back the transaction by using the following appropriate command: rollback transaction
Go

Commit transaction
Go

 
3. Run the following code: sp_configure 'Allow updates', 0
Go
Reconfigure with override
Go

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.