Error Fix – 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
Earlier I have written one article to setup replication in SQL Server 2012 and remove replication from SQL Server 2012. One of the colleagues in my previous company (Yes, I do keep relation with my ex. colleagues :) ) sent me an email to help.
While he was trying to remove publication by following the instruction given in my article “remove replication from SQL Server 2012”, Error seems interesting and looks big but solution to this error is very easy and short. he comes across the following error:
[sourcecode language=”sql”]TITLE: Microsoft SQL Server Management Studio
Could not delete publication ‘AdvertureWorks2012AddressObjects’.
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.0.2100.60&EvtSc=Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.Replication.ReplicationMenuItem&EvtID=CantDeletePublication&LinkId=20476
An exception occurred while executing a Transact-SQL statement or batch.
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 ‘AdventureWorks2012’. (Microsoft SQL Server,Error: 15517)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2218&EvtSrc=MSSQLServer&EvtID=15517&LinkId=20476
Error would looks like this screen capture:
If you are trying removing the publication with the login which has insufficient privileges, you might come across this error. There is one small command to execute to give proper permission to your login. Execute following command in your SQL Server Instance.
ALTER AUTHORIZATION ON DATABASE::[DatabaseName] TO [LoginName];
As soon as you will have proper permission, you will be able to remove publication.
Reference: Ritesh Shah
Note: Microsoft Books online is a default reference of all articles.