Script Method (Replication Objects)
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
The Script method generates a Transact-SQL command batch that can be used to re-create the Microsoft SQL Server component referenced by the SQL Distributed Management Objects (SQL-DMO) object.
HRESULT Script( SQLDMO_REPSCRIPT_TYPE ScriptType = SQLDMORepScript_InstallDistributor, SQLDMO_LPCSTR ScriptFilePath = NULL, SQLDMO_LPBSTR ScriptText = NULL);
SQL-DMO strings are always returned as OLE BSTR objects. A C/C++ application obtains a reference to the string. The application must release the reference using SysFreeString.
When setting the ScriptType argument specifying multiple behaviors, combine values using an OR logical operator. Use these SQLDMO_REPSCRIPT_TYPE values to set ScriptType.
Output to a file is written as ANSI character text.
Output is appended to a designated operating system file. If not set, output overwrites any data in an existing, designated file.
Script includes database object creation.
Script includes deletion of existing database objects.
Script disables a replication database.
Script enables a replication database.
Default. The script installs the replication Distributor.
Script installs a Publisher.
Script installs replication.
No command terminator is added to script commands.
Script creation of publication, excluding push subscriptions.
Script includes publication creation text.
Script includes text that removes publications.
Script pull subscription creation.
Script pull subscription deletion.
Script creation of replication-related jobs to preserve job schedule and steps. The corresponding job script must be run before the replication script. This constant can only be used with Microsoft SQL Server. Only a member of the sysadmin fixed server role or the owner of a job have access to a job creation script.
Output generated by an executed script is directed to an operating system file only. If not set, output is available as status or error messages.
Output to a file is written as Unicode character text.
Script removes the replication Distributor.
Script removes a Publisher.
Script removes replication.
The Script method of replication objects captures an image of a SQL Server replication installation. For example, using the Script method of the TransArticle object generates a command batch that can be used to create the transactional or snapshot replication article referenced, not the object replicated by the article.
To script the creation of a single pull subscription, call the Script method using SQLDMORepScript_PullSubscriptionCreation on a TransPullSubscription or MergePullSubscription object. To script the removal of a single pull subscription, call the Script method using SQLDMORepScript_PullSubscriptionDeletion on a TransPullSubscription or MergePullSubscription object.
To script the creation of pull subscriptions in the TransPullSubscriptions or MergePullSubscriptions collection, call the Script method using SQLDMORepScript_PullSubscriptionCreation. To script the removal of pull subscriptions from the TransPullSubscriptions or MergePullSubscriptions collection, call the Script method using SQLDMORepScript_PullSubscriptionDeletion.
To script the creation of or dropping pull subscriptions in a database, call the Script method using SQLDMORepScript_PullSubscriptionCreation on a ReplicationDatabase object. To script the removal of pull subscriptions from a database, call the Script method using SQLDMORepScript_PullSubscriptionDeletion on a ReplicationDatabase object.
To script the creation of pull subscriptions on a server, call the Script method using SQLDMORepScript_PullSubscriptionCreation on a ReplicationDatabases collection or Subscriber object. To script the removal of pull subscriptions from a server, call the Script method using SQLDMORepScript_PullSubscriptionDeletion on a ReplicationDatabases collection or Subscriber object.
For SQL-DMO objects publish database objects, SQL-DMO implements the ScriptDestinationObject method to generate command batches that re-create the objects published. For more information, see ScriptDestinationObject Method.
SQL-DMO object scripting methods are fully compatible with an instance of SQL Server version 7.0. However, database compatibility level affects Transact-SQL command batch contents.
When scripting a database with a compatibility level of less than 7.0, or when scripting any of its objects, the resulting Transact-SQL command batch includes only keywords reserved by that level.
Transact-SQL command syntax is always compliant with an instance of SQL Server 7.0. Where provided, you can use optional scripting arguments, such as SQLDMOScript2_NoFG to remove some syntax of an instance of SQL Server 7.0.