Rajanand Ilangovan
Rajanand Ilangovan

Rajanand Ilangovan

How to regenerate the sp_MS custom stored procedures in SQL Server

SQL Server Replication

Rajanand Ilangovan's photo
Rajanand Ilangovan
·May 2, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

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:

image.png

Impressum