TechNet
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

sp_replcmds (Transact-SQL)

 

Applies To: SQL Server

Returns the commands for transactions marked for replication. This stored procedure is executed at the Publisher on the publication database.

System_CAPS_ICON_important.jpg Important


The sp_replcmds procedure should be run only to troubleshoot problems with replication.

Topic link icon Transact-SQL Syntax Conventions

  
sp_replcmds [ @maxtrans = ] maxtrans  

[ @maxtrans=] maxtrans
Is the number of transactions to return information about. maxtrans is int, with a default of 1, which specifies the next transaction waiting for distribution.

Column nameData typeDescription
article idintThe ID of the article.
partial_commandbitIndicates whether this is a partial command or not.
commandvarbinary(1024)The command value.
xactidbinary(10)Transaction ID.
xact_seqnovarbinary(16)The transaction sequence number.
publication_idintThe ID of the publication.
command_idintID of the command in MSrepl_commands.
command_typeintType of command.
originator_srvnamesysnameServer where the transaction originated.
originator_dbsysnameDatabase where the transaction originated.
pkHashintInternal use only.
originator_publication_idintID of the publication where the transaction originated.
originator_db_versionintVersion of the database where the transaction originated.
originator_lsnvarbinary(16)Identifies the log sequence number (LSN) for the command in the originating publication.

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). Adding qualified table names allows replication of data from tables owned by a specific user in one database to tables owned by the same user in another database.

System_CAPS_ICON_note.jpg Note


Because the table name in the source database is qualified by the owner name, the owner of the table in the target database must be the same owner name.

Clients who attempt to run sp_replcmds within the same database receive error 18752 until the first client disconnects. After the first client disconnects, another client can run sp_replcmds, and becomes the new log reader.

A warning message number 18759 is added to both the Microsoft SQL Server error log and the Microsoft Windows application log if sp_replcmds is unable to replicate a text command because the text pointer was not retrieved in the same transaction.

Only members of the sysadmin fixed server role or the db_owner fixed database role can execute sp_replcmds.

Error Messages
sp_repldone (Transact-SQL)
sp_replflush (Transact-SQL)
sp_repltrans (Transact-SQL)
System Stored Procedures (Transact-SQL)

Community Additions

ADD
Show:
© 2016 Microsoft