删除或修改表时提示:无法更改表,因为它正在为复制而发布

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 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
     
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值