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. (Source: MSSQLServer, Error number: 15517)

-> I was working on a transactional replication issue.

-> The log and distribution agent were failing with below error,

Error messages:
The process could not execute ‘sp_replcmds’ on ‘jbpub-DR’. (Source: MSSQL_REPL, Error number: MSSQL_REPL20011)
Get help: http://help/MSSQL_REPL20011
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. (Source: MSSQLServer, Error number: 15517)
Get help: http://help/15517
The process could not execute ‘sp_replcmds’ on ‘jbpub-DR’. (Source: MSSQL_REPL, Error number: MSSQL_REPL22037)
Get help: http://help/MSSQL_REPL22037

-> The database used in this replication process is Accounts. As per the error message I checked the database owner and could see that it was blank as shown in below screenshot,

-> I changed the database owner to sa using below query,

USE [Accounts]
 GO
 ALTER AUTHORIZATION ON DATABASE::[Accounts] TO [sa]
 GO

-> I restarted the log and distribution agent. It completed fine this time.

Thank You,
Vivek Janakiraman

Disclaimer:
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.