SQL Server script to remove replication

replicationsql-server-2005

I have been asked to write a SQL script that can be run, which will stop replication and remove the subscriber/subscription.

Is this at all possible? Or do you have to use the GUI?

Best Solution

Which version of SQL Server you are using.

Try

sp_removedbreplication 'DB_PROD' 
go

Related Read - How to cleanup Replication Bits - http://blogs.msdn.com/b/repltalk/archive/2010/11/17/how-to-cleanup-replication-bits.aspx

Google as well provides MSDN article in results

How to: Disable Publishing and Distribution (Replication Transact-SQL Programming) - http://msdn.microsoft.com/en-us/library/ms147921.aspx