How to regenerate the sp_MS custom stored procedures in SQL Server

SQL Server Replication

If you are adding a subscription using "initialize with LSN" option when the log reader agent is stopped, the auto generated stored procs will not be generated. You can use the below script to generate it.

This script will generate the below stored procedures for each of the table article that are replicated.

  • sp_MSins*
  • sp_MSupd*
  • sp_MSdel*
USE your_publisher_db;
exec sp_scriptpublicationcustomprocs @publication = 'your_publication_name'

Once you execute, you will get the stored procedure definitions. You can just copy that and execute it in subscriber database to create the stored procedures. The generated stored procedure's schema is based on the publisher database's schema.

Sample Output: