-> I tried dropping a publication in a transactional replication setup and received below error,
TITLE: Microsoft SQL Server Management Studio
Could not delete publication ‘JBDBREP’.
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=15.0.18338.0&EvtSrc=Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.Replication.ReplicationMenuItem&EvtID=CantDeletePublication&LinkId=20476
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot execute as the database principal because the principal “dbo” does not exist, this type of principal cannot be impersonated, or you do not have permission.
Changed database context to ‘JBDBREPL’. (Microsoft SQL Server, Error: 15517)
-> The error message points to some issue related to owner of the replicated database.
-> Right click the publisher database and click on properties. Click on “Files” tab and check for Owner.
-> In my case I see it blank and this seems to be the problem.
-> I executed below query to change the owner to SA. Instead of SA an appropriate login will also help.
ALTER AUTHORIZATION ON DATABASE::[JBDBREPL] TO [sa]
-> I tried removing the publication and it worked fine this time.
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.