Partager via


ScriptDestinationObject2 Method (MergeArticle2)

Cette fonctionnalité sera supprimée dans une prochaine version de Microsoft SQL Server. Évitez d'utiliser cette fonctionnalité dans de nouveaux travaux de développement, et prévoyez de modifier les applications qui utilisent actuellement cette fonctionnalité.

The ScriptDestinationObject2 method generates a Transact-SQL command batch that can be used to create the replicated image of the database object published by the referenced replication article.

Syntaxe

object
.ScriptDestinationObject2( 
[ ScriptType ] , 
[ ScriptFilePath ] , 
[ Script2Type ] , 
[ bstrDestinationObject ] ) 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 script.
  • Script2Type
    Optional. A long integer that overrides default scripting behavior as described in Settings.
  • bstrDestinationObject
    Object name at the Subscriber destination if different from the source name.

Prototype (C/C++)

HRESULT ScriptDestinationObject2(
SQLDMO_SCRIPT_TYPE,
SQLDMO_LPCSTR ScriptFilePath,
SQLDMO_LPBSTR ScriptText,
SQLDMO_SCRIPT2_TYPE Script2Type,
SQLDMO_LPCSTR pszDestinationObject;
ms135035.note(fr-fr,SQL.90).gifRemarque :
SQL Distributed Management Objects (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 values to set ScriptType.

Constant Value Description

SQLDMOScript_Aliases

16384

Obsolete.

SQLDMOScript_AppendToFile

256

Object Script method only. Append to indicated output file. By default, Script method overwrites existing file.

SQLDMOScript_Bindings

128

Generate sp_bindefault and sp_bindrule statements. Applies only when scripting references a SQL Server table.

SQLDMOScript_/ClusteredIndexes

8

Generate Transact-SQL defining clustered indexes. Applies only when scripting references a SQL Server table.

SQLDMOScript_/DatabasePermissions

32

Generate Transact-SQL database privilege defining script. Database permissions grant or deny statement execution rights.

SQLDMOScript_Default

4

SQLDMOScript_PrimaryObject.

SQLDMOScript_DRI_All

532676608

All values defined as SQLDMOScript_DRI_... combined using an OR logical operator.

SQLDMOScript_DRI_/AllConstraints

520093696

SQLDMOScript_DRI_Checks, SQLDMOScript_DRI_Defaults, SQLDMOScript_DRI_ForeignKeys, SQLDMOScript_DRI_PrimaryKey, and SQLDMOScript_DRI_UniqueKeys combined using an OR logical operator.

SQLDMOScript_DRI_/AllKeys

469762048

SQLDMOScript_DRI_ForeignKeys, SQLDMOScript_DRI_PrimaryKey, SQLDMOScript_DRI_UniqueKeys combined using an OR logical operator.

SQLDMOScript_DRI_/Checks

16777216

Generated script creates column-specified CHECK constraints. Directs scripting when declarative referential integrity establishes dependency relationships. Applies only when scripting references a SQL Server table.

SQLDMOScript_DRI_/Clustered

8388608

Generated script creates clustered indexes. Directs scripting when declarative referential integrity establishes dependency relationships. Applies only when scripting references a SQL Server table.

SQLDMOScript_DRI_/Defaults

33554432

Generated script includes column-specified defaults. Directs scripting when declarative referential integrity establishes dependency relationships. Applies only when scripting references a SQL Server table.

SQLDMOScript_DRI_/ForeignKeys

134217728

Generated script creates FOREIGN KEY constraints. Directs scripting when declarative referential integrity establishes dependency relationships. Applies only when scripting references a SQL Server table.

SQLDMOScript_DRI_/NonClustered

4194304

Generated script creates nonclustered indexes. Directs scripting when declarative referential integrity establishes dependency relationships. Applies only when scripting references a SQL Server table.

SQLDMOScript_DRI_/PrimaryKey

268435456

Generated script creates PRIMARY KEY constraints. Directs scripting when declarative referential integrity establishes dependency relationships. Applies only when scripting references a SQL Server table.

SQLDMOScript_DRI_/UniqueKeys

67108864

Generated script creates candidate keys defined using a unique index. Directs scripting when declarative referential integrity establishes dependency relationships. Applies only when scripting references a SQL Server table.

SQLDMOScript_DRIIndexes

65536

When SQLDMOScript_NoDRI is specified, script PRIMARY KEY constraints using a unique index to implement the declarative referential integrity. Applies only when scripting references a SQL Server table.

SQLDMOScript_/DRIWithNoCheck

536870912

When using SQLDMOScript_DRI_Checks, or SQLDMOScript_DRI_ForeignKeys, generated script includes the WITH NOCHECK clause optimizing constraint creation. Applies only when scripting references a SQL Server table.

SQLDMOScript_Drops

1

Generate Transact-SQL to remove referenced component. Script tests for existence prior attempt to remove component.

SQLDMOScript_/IncludeHeaders

131072

Generated script is prefixed with a header containing date and time of generation and other descriptive information.

SQLDMOScript_/IncludeIfNotExists

4096

Transact-SQL creating a component is prefixed by a check for existence. When script is executed, component is created only when a copy of the named component does not exist.

SQLDMOScript_Indexes

73736

SQLDMOScript_ClusteredIndexes, SQLDMOScript_NonClusteredIndexes, and SQLDMOScript_DRIIndexes combined using an OR logical operator.

SQLDMOScript_Indexes

73736

Now applies to both table and view objects.

SQLDMOScript_/NoCommandTerm

32768

Individual Transact-SQL statements in the script are not delimited using the connection-specific command terminator. By default, individual Transact-SQL statements are delimited.

SQLDMOScript_NoDRI

512

Generated Transact-SQL statements do not include any clauses defining declarative referential integrity constraints. Applies only when scripting references a SQL Server table. Only use when script will execute on a version 4.21a SQL Server installation.

SQLDMOScript_NoIdentity

1073741824

Generated Transact-SQL statements do not include definition of identity property, seed, and increment. Applies only when scripting references a SQL Server table.

SQLDMOScript_/NonClusteredIndexes

8192

Generate Transact-SQL defining nonclustered indexes. Applies only when scripting references a SQL Server table.

SQLDMOScript_/ObjectPermissions

2

Include Transact-SQL privilege defining statements when scripting database objects.

SQLDMOScript_OwnerQualify

262144

Object names in Transact-SQL generated to remove an object are qualified by the owner of the referenced object. Transact-SQL generated to create the referenced object qualify the object name using the current object owner.

SQLDMOScript_Permissions

34

SQLDMOScript_ObjectPermissions and SQLDMOScript_DatabasePermissions combined using an OR logical operator.

SQLDMOScript_/PrimaryObject

4

Generate Transact-SQL creating the referenced component.

SQLDMOScript_SortedData

1048576

Obsolete.

SQLDMOScript_/SortedDataReorg

2097152

Obsolete.

SQLDMOScript_/TimestampToBinary

524288

When scripting object creation for a table or user-defined data type, convert specification of timestamp data type to binary(8).

SQLDMOScript_ToFileOnly

64

Most SQL-DMO object scripting methods specify both a return value and an optional output file. When used, and an output file is specified, the method does not return the script to the caller, but only writes the script to the output file.

SQLDMOScript_/TransferDefault

422143

Default. SQLDMOScript_PrimaryObject, SQLDMOScript_Drops, SQLDMOScript_Bindings, SQLDMOScript_ClusteredIndexes, SQLDMOScript_NonClusteredIndexes, SQLDMOScript_Triggers, SQLDMOScript_ToFileOnly, SQLDMOScript_Permissions, SQLDMOScript_IncludeHeaders, SQLDMOScript_Aliases, SQLDMOScript_IncludeIfNotExists, and SQLDMOScript_OwnerQualify combined using an OR logical operator.

SQLDMOScript_Triggers

16

Generate Transact-SQL defining triggers. Applies only when scripting references a SQL Server table.

SQLDMOScript_/UDDTsToBaseType

1024

Convert specification of user-defined data types to the appropriate SQL Server base data type. Applies only when scripting references a SQL Server table.

SQLDMOScript_/UseQuotedIdentifiers

-1

Use quote characters to delimit identifier parts when scripting object names.

When setting the Script2Type argument specifying multiple behaviors, combine values using an OR logical operator. Use these values to set Script2Type.

Constant Value Description

SQLDMOScript2_AnsiFile

2

Create output file as a multibyte character text file. Code page 1252 is used to determine character meaning.

SQLDMOScript2_/AnsiPadding

1

Command batch includes the SET ANSI_PADDING ON and SET ANSI_PADDDING OFF Transact-SQL statements before and after CREATE TABLE statements in the generated script. Use when the article publishes a table.

SQLDMOScript2_Default

0

Default. No scripting options specified.

SQLDMOScript2_/ExtendedProperty

4194304

Include extended property scripting as part of object scripting.

SQLDMOScript2_/FullTextIndex

524288

Command batch includes statements that define Microsoft Search full-text indexing. Use when the article publishes a table.

SQLDMOScript2_NoCollation

8388608

Do not script the collation clause if source is later than SQL Server version 7.0. The default is to generate collation.

SQLDMOScript2_NoFG

16

Command batch does not include 'ON <filegroup>' clause that directs filegroup use. Use when the article publishes a table.

SQLDMOScript2_/NoWhatIfIndexes

512

Command batch does not include CREATE STATISTICS statements. Use when the article publishes a table.

SQLDMOScript2_UnicodeFile

4

Create output file as a Unicode character text file.

Returns

A Transact-SQL command batch as a string.

Notes

For SQL-DMO objects that publish database objects, SQL-DMO implements the ScriptDestinationObject2 method to generate command batches that re-create the published objects.

ms135035.note(fr-fr,SQL.90).gifRemarque :
If an application calls ScriptDestinationObject2 on an instance of SQL Server version 7.0, the constant, SQLDMO_E_SQL80ONLY, and the message "This property or method requires Microsoft SQL Server 2000 or later" are returned.

Applies To:

MergeArticle2 Object