Script Method (Replication Objects)
この機能は、将来のバージョンの Microsoft SQL Server では削除される予定です。新規の開発作業ではこの機能を使用しないようにし、現在この機能を使用しているアプリケーションは修正することを検討してください。
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.
構文
object
.Script( [ ScriptType ] , [ ScriptFilePath ] )as String
Parts
- object
Expression that evaluates to an object in the Applies To list.
- ScriptType
Optional. A long integer that overrides default scripting behavior as described in Settings.
- ScriptFilePath
Optional. A string that specifies an operating system file as an additional target for the generated Transact-SQL statements script.
Prototype (C/C++)
HRESULT Script(
SQLDMO_REPSCRIPT_TYPE ScriptType = SQLDMORepScript_Default,
SQLDMO_LPCSTR ScriptFilePath = NULL,
SQLDMO_LPBSTR ScriptText = NULL);
(Distributor 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. |
Settings
When setting the ScriptType argument specifying multiple behaviors, combine values using an OR logical operator. Use these SQLDMO_REPSCRIPT_TYPE values to set ScriptType.
Constant | Value | Description |
---|---|---|
SQLDMORepScript_AnsiFile |
16777216 |
Output to a file is written as ANSI character text. |
SQLDMORepScript_/AppendToFile |
8192 |
Output is appended to a designated operating system file. If not set, output overwrites any data in an existing, designated file. |
SQLDMORepScript_/Creation |
16384 |
Script includes database object creation. |
SQLDMORepScript_Default |
256 |
SQLDMORepScript_InstallDistributor. |
SQLDMORepScript_Deletion |
32768 |
Script includes deletion of existing database objects. |
SQLDMORepScript_/DisableReplicationDB |
134217728 |
Script disables a replication database. |
SQLDMORepScript_/EnableReplicationDB |
67108864 |
Script enables a replication database. |
SQLDMORepScript_/InstallDistributor |
256 |
Default. The script installs the replication Distributor. |
SQLDMORepScript_/InstallPublisher |
1024 |
Script installs a Publisher. |
SQLDMORepScript_/InstallReplication |
1048576 |
Script installs replication. |
SQLDMORepScript_/NoCommandTerm |
268435456 |
No command terminator is added to script commands. |
SQLDMORepScript_/NoSubscription |
128 |
Script creation of publication, excluding push subscriptions. |
SQLDMORepScript_/PublicationCreation |
65536 |
Script includes publication creation text. |
SQLDMORepScript_/PublicationDeletion |
131072 |
Script includes text that removes publications. |
SQLDMORepScript_/PullSubscriptionCreation |
262144 |
Script pull subscription creation. |
SQLDMORepScript_/PullSubscriptionDeletion |
524288 |
Script pull subscription deletion. |
SQLDMORepScript_/ReplicationJobs |
4194304 |
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. |
SQLDMORepScript_/SubscriptionCreation |
262144 |
Obsolete. |
SQLDMORepScript_/SubscriptionDeletion |
524288 |
Obsolete. |
SQLDMORepScript_/ToFileOnly |
4096 |
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. |
SQLDMORepScript_/UnicodeFile |
33554432 |
Output to a file is written as Unicode character text. |
SQLDMORepScript_/UninstallDistributor |
512 |
Script removes the replication Distributor. |
SQLDMORepScript_/UninstallPublisher |
2048 |
Script removes a Publisher. |
SQLDMORepScript_/UninstallReplication |
2097152 |
Script removes replication. |
Returns
A Transact-SQL command batch as a string.
解説
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.
Applies To:
|