I have an issue with SQL replication that I am having trouble fixing. What I am doing is restoring two DBs from a production backup, and then installing replication between them. The replication seems to be configured without any errors, but when I look at the status I see error messages like this:
Error messages:
The process could not execute 'sp_replcmds' on 'MYSERVER1'. 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 'MYSERVER1'. Get help: http://help/MSSQL_REPL22037
What does this mean?
sp_replcmds is used by the log reader process in transactional replication. Replication treats the first client that runs sp_replcmds within a given database as the log reader. This procedure can generate commands for owner-qualified tables or not qualify the table name (the default).
Often this error message can come from the database not having a valid owner, or the SQL Server is not being able to correctly identify the owner of the database. Often this is easiest to fix by changing the database owner by using the sp_changedbowner system stored procedure as shown below.
sp_replflush is used in transactional replication. Article definitions are stored in the cache for efficiency. sp_replflush is used by other replication stored procedures whenever an article definition is modified or dropped. Only one client connection can have log reader access to a given database.
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. It is very simple to fix the error. It happens because of the database owner is blank in the database properties for the file.
When I had this problem, my database didn't have an owner set properly. I had restored a database from another windows domain, right clicked the database -> properties and verified in the "general" tab that the owner was set correctly. However, in the "files" tab, owner was not set at all. As soon as I set it, replication was running without problems.
'dbo' maps to a login that is invalid. If you run select suser_sname(owner_sid) from sys.databases
, you probaly get NULL for those two DBs. You need to change 'dbo' to a valid login. Run, on both databases:
ALTER AUTHORIZATION ON DATABASE::[<dbname>] TO [sa]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With