Collapse the table of content
Expand the table of content


SQL Server 2000

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 [ @publication = ] publication
    [ , [ @scriptfile = ] 'scriptfile' ]
    [ , [ @skiperror = ] 'skiperror' ]


[@publication = ] 'publication'

Is the name of the publication. publication is sysname, with no default.

[@scriptfile = ] 'scriptfile'

Is the full path to the SQL script file. scriptfile is nvarchar(4000), with no default.

[@skiperror = ] 'skiperror'

Inicates whether the Distribution Agent or Merge Agent should stop when an error is encountered during script processing. SkipError is bit, with a default of 0. If 0, the Distribution Agent or Merge Agent stops. If 1, the Distribution Agent or Merge Agent continues the script and ignores the error.

Return Code Values

0 (success) or 1 (failure)


sp_addscriptexec is used in transactional replication and merge replication.

sp_addscriptexec is not used for snapshot replication.

sp_addscriptexec is useful in applying scripts to subscribers, and uses osql.exe 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. The SkipError bit gives the user the ability to have the Distribution Agent or Merge Agent ignore errors and continue on. Use osql.exe to test scripts prior to running sp_addscriptexec.

Note that skipped errors will continue to be logged in the Agent history for reference. For more information, see Viewing Agent History.


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

See Also

Agents and Monitors

How to monitor replication agent history (Enterprise Manager)

System Stored Procedures

© 2016 Microsoft