Posts a SQL script (.sql file) to all Subscribers of a publication. This stored procedure is executed at the Publisher on the publication database.
sp_addscriptexec is used in transactional replication and merge replication.
sp_addscriptexec is not used for snapshot replication.
To use sp_addscriptexec, the SQL Server service account must have read and write permissions on the snapshot location and read permissions on the location where any scripts are stored.
The sqlcmd utility is used to execute the script at the Subscriber, and the script is executed in the security context used by the Distribution Agent or Merge Agent when connecting to the subscription database. When the agent is run on a previous version of SQL Server, the osql utility is used instead of sqlcmd.
sp_addscriptexec is useful in applying scripts to subscribers, and uses sqlcmd to apply the contents of the script to the Subscriber. However, because Subscriber configurations can vary, scripts tested prior to posting to the Publisher may still cause errors on a Subscriber. skiperror provides the ability to have the Distribution Agent or Merge Agent ignore errors and continue on. Use sqlcmd to test scripts prior to running sp_addscriptexec.
Skipped errors will continue to be logged in the Agent history for reference.
Using sp_addscriptexec to post a script file for publications using FTP for snapshot delivery is only supported for Microsoft SQL Server Subscribers.