Using a script which you can generate through SQL Server Replication, I am trying to drop the subscription and publication as part of a job:
-- Dropping the transactional subscriptions
EXEC
NTTMI.sys.sp_dropsubscription
@publication = N'NTTMI_STAGING_TEST',
@subscriber = N'PENGUIN',
@destination_db = N'NTTMI_STAGING',
@article = N'all'
-- Dropping the transactional articles
EXEC
NTTMI.sys.sp_dropsubscription
@publication = N'NTTMI_STAGING_TEST',
@article = N'CallScripterSource',
@subscriber = N'all',
@destination_db = N'all'
EXEC
NTTMI.sys.sp_droparticle
@publication = N'NTTMI_STAGING_TEST',
@article = N'CallScripterSource',
@force_invalidate_snapshot = 1
-- Dropping the transactional publication
EXEC
NTTMI.sys.sp_droppublication
@publication = N'NTTMI_STAGING_TEST'
-- Disabling the replication database
EXEC
master.sys.sp_replicationdboption
@dbname = N'NTTMI',
@optname = N'publish',
@value = N'false'
exec NTTMI.sys.sp_subscription_cleanup
@publisher = 'Penguin', @publisher_db = 'NTTMI', @publication = 'NTTM_STAGING_TEST'
However, when I check the replication folder after the publication is gone but the local subscription is still visible (see image below). Is there something I am missing?