Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 replication failing with: process could not execute 'sp_replcmds'

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?

like image 880
skb Avatar asked Apr 27 '10 16:04

skb


People also ask

What is Sp_replcmds?

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).

Could not execute sp_ replcmds?

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.

What is Sp_replflush?

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.

Can not execute as the database principal?

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.


2 Answers

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.

like image 151
Mattias Nordqvist Avatar answered Sep 18 '22 09:09

Mattias Nordqvist


'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] 
like image 22
Remus Rusanu Avatar answered Sep 19 '22 09:09

Remus Rusanu