Solved

Cannot drop the database, it's being used for replication

Posted on 2006-07-12
16
828 Views
Last Modified: 2008-01-09
Restored a database, and it looks like a system distributed database, it just has system tables in it. I'm not using replication and now I can't delete the database. There are no items on under replication for publications or subscriptions.

Help
0
Comment
Question by:JRockFL
16 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
Comment Utility
consider running

sp_removedbreplication

0
 
LVL 8

Author Comment

by:JRockFL
Comment Utility
Thank you for your reply. I tried that and I still get the same error message  :(
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility

How to manually remove a replication in SQL Server 2000 or in SQL Server 2005
http://support.microsoft.com/default.aspx?scid=kb;en-us;324401
0
 
LVL 8

Author Comment

by:JRockFL
Comment Utility
There are no replications setup. I restored a database that has all the system replicaiton tables. i.e. MSnapshot_history etc..etc.
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility


try:

USE master
GO
EXEC sp_replicationdboption @dbname = N'<Publication database name>', @optname = N'publish', @value = N'false'
0
 
LVL 9

Expert Comment

by:nito8300
Comment Utility
Did you try detaching or taking the database offline and then deleting?
0
 

Expert Comment

by:shanncan
Comment Utility
It maybe possible that there is a lock on one of the tables.

Have you tried checking for open handles on any of the tables?

To do this go to Enterprise Manager -> Management-> Locks/Objects
 and check if the database is being used by another process. If it is - then kill the process.

then : in query analyser

drop database <database name>

The actual path to check the locks on the objects that I have written above is just off the top of my head - but you'll know what im talking about when you get down to the 'management' bit.
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
Plan B':


You can  restore another database backup, that don`t have replications configured,  over the database that you want to delete(with the "force restore over existing database" option marked). Doing this you will overwrite the sysobjects lines that saves the replication parameters and the SQL Server will alow you to delete the database.

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 8

Author Comment

by:JRockFL
Comment Utility
EugeneZ,
The command executed properly. But I still can't drop it.

shanncan,
there were no open handles. I'm rebooting the server.

nito8300,
It doesnt have take offline as an option. All the tables that are in there are system created tables.
It "thinks" it's a system database or something.
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
so what about plan B'?
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
did you try:

use master
go
exec sp_removedbreplication 'yourDB'
go
drop database 'yourDB'
0
 
LVL 8

Author Comment

by:JRockFL
Comment Utility
Yes, I used that...
use master
go
exec sp_removedbreplication 'test'
go
drop database test

Server: Msg 3724, Level 16, State 3, Line 1
Cannot drop the database 'test' because it is being used for replication.

What else can we try??
0
 
LVL 42

Accepted Solution

by:
EugeneZ earned 500 total points
Comment Utility
plan B':
Create a dummy, temp database called 'test1' .
Backup the database.
Restore the backup over the database you can't delete (you'll have to rename the target file so as to not conflict with your original, dummy, temp database).
 delete both databases
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
Back to plan A":

From the BOL:
To disable replication using the SQL Server Enterprise Manager

  1. Expand a server group, and then expand the Distributor (the server
that contains the distribution database).
  2. Right-click the Replication folder, and then click Disable Publishing.
  3. Complete the steps in the Disable Publishing and Distribution Wizard.
==============
Also:
PRB: You receive error 3724 when you drop a non-replicated object
http://support.microsoft.com/default.aspx?scid=kb;en-us;326352
0
 
LVL 8

Author Comment

by:JRockFL
Comment Utility
EugeneZ,

Thank you so much! Plan B worked!!!
0
 
LVL 8

Author Comment

by:JRockFL
Comment Utility
Thank you for your dedication to helping me solve this problem.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now