How to delete SQL server replication

On SQL Server 2008 R2, I am trying to setup transactional replication with test data and I'm getting an error:  
SQL Server could not create publication PubOne.
Database 'distribution' does not exist.  

This probably occurs because I previously tried to setup replication,
dropped my test databases, dropped distribution, and started over.

How do I fix this mess and truly start over?  


Here's what I tried to delete replication:

alter database ReplicationSource set offline
alter database ReplicationTarget set offline
alter database distribution      set offline
go

drop database ReplicationSource -- and remove disk files
drop database ReplicationTarget -- and remove disk files
drop database distribution      -- and remove disk files
go

exec sp_removeDbReplication 'ReplicationSource'
exec sp_removeDbReplication 'ReplicationTarget'
go

exec sp_dropdistributor   -- fails with    Could not drop the Distributor 'DAVIDZ-PC'. This Distributor has associated distribution databases.
go
CFS_developerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Did you follow this MSDN article?
Jason clarkDBA FreelancerCommented:
sp_removedbreplication

This procedure should be used only if other methods of removing replication objects have failed. For more information about these methods.

To know more click on this https://technet.microsoft.com/en-us/library/ms152757(v=sql.105).aspx
CFS_developerAuthor Commented:
Gentlemen,

The procedures you cite would have been great if I started with them.  Unfortunately, I didn't know what I was doing, so I just dropped all relevant databases (distribution, replication source, replication target).  But now the database server thinks replication is still going.  How do I finally kill replication and start over?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Check if the query returns any '1' for the columns. If it does you need to update it to zero (0):
SELECT name, is_distributor, is_publisher, is_subscriber
FROM master.sys.servers

Open in new window

CFS_developerAuthor Commented:
Victor,

I found 3 commands which seemed to do the trick:
 
  exec sp_dropDistPublisher @publisher='MyPublisherName', @no_checks=1, @ignore_distributor=1
  exec sp_dropDistributionDb distribution
  exec sp_dropDistributor @ignore_distributor=1

I also executed your query and all columns came back as zero.  I think it might even be fixed!
Vitor MontalvãoMSSQL Senior EngineerCommented:
Great. Those check and ignore parameters might did the trick.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CFS_developerAuthor Commented:
My input provided part of the solution
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.