您的位置:首页 > 运维架构

Cannot drop the database XXX because it is being used for replication

2015-03-18 10:13 686 查看
解决方法

1、Recreate a replication on this DB for the purpose dropping it.  After I drop the replication, I was able to drop the DB.

2、将数据库Offline然后再删除就可以了

SQL 2000的脚本

-- Removes Replication Flag for all Tables in the Database
-- using sp_MSunmarkreplinfo
SET NOCOUNT ON
DECLARE @tablename NVARCHAR(128)
DECLARE @RC INT
DECLARE curTable CURSOR FOR
SELECT [name] AS tbl
FROM sys.tables
OPEN curTable
FETCH NEXT FROM curTable
INTO @tablename
WHILE @@FETCH_STATUS = 0
BEGIN
EXECUTE @RC = dbo.sp_MSunmarkreplinfo @tablename
FETCH NEXT FROM curTable
INTO @tablename
END
CLOSE curTable
DEALLOCATE curTable
GO




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mssql 数据库
相关文章推荐