Log Reader Agent failing to initialize
Yestarday i was setting up a transacional replication and after all the process that you should do to configure one the Log Agent Reader Monitor was showing these messages to me:
The process could not execute ‘sp_replcmds’ on ‘DB01’. (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 ‘DB01’. (Source: MSSQL_REPL, Error number: MSSQL_REPL22037)
Get help: http://help/MSSQL_REPL22037
The solution for these messages is a quite simple. This happens because the schema “DBO” maps to a login that doesn’t exists. Running this query select suser_sname(owner_sid) from sys.databases you might get a NULL value, so the only option you have is change the owner for a valid login.
ALTER AUTHORIZATION ON DATABASE::DATABASE TO SOME_LOGIN
After that, the replication should run fine..