Exporter (0) Imprimer
Développer tout

Classe ScriptingOptions

The ScriptingOptions object provides programmatic options to the options that can be set for scripting operations.

System..::..Object
  Microsoft.SqlServer.Management.Smo..::..ScriptingOptions

Espace de noms :  Microsoft.SqlServer.Management.Smo
Assembly :  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

public sealed class ScriptingOptions

Le type ScriptingOptions expose les membres suivants.

  NomDescription
Méthode publiqueScriptingOptions()()()()Initializes a new instance of the ScriptingOptions class.
Méthode publiqueScriptingOptions(ScriptingOptions)Initializes a new instance of the ScriptingOptions class based on the specified scripting options.
Méthode publiqueScriptingOptions(ScriptOption)Initializes a new instance of the ScriptingOptions class based on the specified ScriptOption object, based on the specified script option.
Haut de la page

  NomDescription
Propriété publiqueAgentAlertJobGets or sets the Boolean property that specifies whether to include SQL Server Agent job name for alert objects in the script.
Propriété publiqueAgentJobIdGets or sets the Boolean property that specifies whether to include SQL Server Agent job ID values for alert objects in the script.
Propriété publiqueAgentNotifyGets or sets the Boolean property that specifies whether to include notifications for any SQL Server Agent alerts that are in the script.
Propriété publiqueAllowSystemObjectsGets or sets the Boolean property that specifies whether system objects can be scripted.
Propriété publiqueAnsiFileGets or sets the Boolean property that specifies whether the script uses multibyte characters and requires code page 1252 to evaluate characters' meaning.
Propriété publiqueAnsiPaddingGets or sets a Boolean property that specifies whether the generated script contains the Transact-SQL statements SET ANSI-PADDING ON and SET ANSI-PADDING OFF before and after the CREATE TABLE statement, respectively.
Propriété publiqueAppendToFileGets or sets a Boolean property value that specifies whether the script is appended to the end of the output file or overwrites it.
Propriété publiqueBatchSizeGets or sets the number of statements after which to script batch terminator.
Propriété publiqueBindingsGets or sets a Boolean property value that specifies whether the binding statements sp_binddefault and sp_bindrule are included in the generated script. This property applies only when scripting a SQL Server table.
Propriété publiqueChangeTrackingGets or sets the ChangeTracking property value.
Propriété publiqueClusteredIndexesGets or sets a Boolean property value that specifies whether statements that define clustered indexes are included in the generated script.
Propriété publiqueContinueScriptingOnErrorGets or sets the Boolean property value that specifies whether the scripting operation continues after an error is encountered.
Propriété publiqueConvertUserDefinedDataTypesToBaseTypeGets or sets the Boolean property value that specifies whether user-defined data types are converted to the most appropriate SQL Server base data types in the generated script.
Propriété publiqueDdlBodyOnlyGets or sets the Boolean property value that specifies whether to script only the text definition for data definition language (DDL) objects that have a text body, such as stored procedures and triggers.
Propriété publiqueDdlHeaderOnlyGets or sets the Boolean property value that specifies whether to script only the header information for data definition language (DDL) objects that have a text body, such as stored procedures and triggers.
Propriété publiqueDefaultGets or sets the Boolean property value that specifies whether the creation of the referenced object is included in the generated script.
Propriété publiqueDriAllGets or sets the Boolean property value that specifies whether all DRI objects are included in the generated script.
Propriété publiqueDriAllConstraintsGets or sets the Boolean property value that specifies whether all declarative referential integrity constraints are included in the generated script.
Propriété publiqueDriAllKeysGets or sets the Boolean property value that specifies whether the dependency relationships defined by all declarative referential integrity keys are included in the generated script.
Propriété publiqueDriChecksGets or sets the Boolean property value that specifies whether column specific dependency relationships as defined in check constraints with enforced declarative referential integrity are included in the script.
Propriété publiqueDriClusteredGets or sets the Boolean property value that specifies whether dependency relationships defined in clustered indexes with enforced declarative referential integrity are included in the script.
Propriété publiqueDriDefaultsGets or sets the Boolean property value that specifies whether dependency relationships defined in defaults with enforced declarative referential integrity are included in the script.
Propriété publiqueDriForeignKeysGets or sets the Boolean property value that specifies whether dependency relationships defined in foreign keys with enforced declarative referential integrity are included in the script.
Propriété publiqueDriIncludeSystemNamesGets or sets the Boolean property value that specifies whether the system-generated constraint names that are used to enforce declarative referential integrity are included in the script.
Propriété publiqueDriIndexesGets or sets the Boolean property value that specifies whether PRIMARY KEY constraints that use a unique index to implement the declarative referential integrity are included in the script.
Propriété publiqueDriNonClusteredGets or sets the Boolean property value that specifies whether dependency relationships that are defined in non-clustered indexes that have enforced declarative referential integrity are included in the script.
Propriété publiqueDriPrimaryKeyGets or sets the Boolean property value that specifies whether dependency relationships that are defined in primary keys which have enforced declarative referential integrity are included in the script.
Propriété publiqueDriUniqueKeysGets or sets the Boolean property value that specifies whether dependency relationships that are defined in unique keys which have enforced declarative referential integrity are included in the script.
Propriété publiqueDriWithNoCheckGets or sets the Boolean property value that specifies whether the no check statement is included in the script.
Propriété publiqueEncodingGets or sets the encoding for the scripting options.
Propriété publiqueEnforceScriptingOptionsGets or sets the Boolean property value that specifies whether the application of all scripting options is enforced for text-based objects, such as SchemaQualify.
Propriété publiqueExtendedPropertiesGets or sets the Boolean property value that specifies whether extended object properties are included in the generated script.
Propriété publiqueFileNameGets or sets the name of the file to which the generated script is output.
Propriété publiqueFullTextCatalogsGets or sets the Boolean property value that specifies whether full-text catalogs are included in the generated script.
Propriété publiqueFullTextIndexesGets or sets the Boolean property value that specifies whether full-text indexes are included in the generated script.
Propriété publiqueFullTextStopListsGets or sets the Boolean property value that specifies whether full-text stop lists are included in the generated script.
Propriété publiqueIncludeDatabaseContextGets or sets the Boolean property value that specifies whether database context is included in the generated script.
Propriété publiqueIncludeDatabaseRoleMembershipsGets or sets the IncludeDatabaseRoleMemberships property value.
Propriété publiqueIncludeFullTextCatalogRootPathGets or sets the IncludeFullTextCatalogRootPath property value.
Propriété publiqueIncludeHeadersGets or sets a Boolean property value that specifies whether the generated script is prefixed with a header that contains information which includes the date and time of generation.
Propriété publiqueIncludeIfNotExistsGets or sets a Boolean property value that specifies whether to check the existence of an object before including it in the script.
Propriété publiqueIndexesGets or sets the Boolean property value that specifies whether indexes are included in the generated script.
Propriété publiqueLoginSidGets or sets the Boolean property value that specifies whether the security identifiers are included for any scripted logins in the generated script.
Propriété publiqueNoAssembliesGets or sets the Boolean property value that specifies whether assemblies are included in the generated script.
Propriété publiqueNoCollationGets or sets the Boolean property value that specifies whether to include the collation clause in the generated script.
Propriété publiqueNoCommandTerminatorGets or sets the Boolean property value that specifies whether individual Transact-SQL statements are delimited in the generated script.
Propriété publiqueNoExecuteAsGets or sets the Boolean property value that specifies whether the EXECUTE AS options for stored procedures and user-defined functions are included in the script.
Propriété publiqueNoFileGroupGets or sets the Boolean property value that specifies whether to include the 'ON <filegroup>' clause in the generated script.
Propriété publiqueNoFileStreamGets or sets an object that specifies whether to include the FILESTREAM_ON clause when you create VarBinaryMax columns in the generated script.
Propriété publiqueNoFileStreamColumnGets or sets an object that specifies whether to include the FILESTREAM_ON clause when you create VarBinaryMax columns in the generated script.
Propriété publiqueNoIdentitiesGets or sets the Boolean property value that specifies whether definitions of identity property seed and increment are included in the generated script.
Propriété publiqueNoIndexPartitioningSchemesGets or sets the Boolean property value that specifies whether partition schemes for indexes are included in the generated script.
Propriété publiqueNoMailProfileAccountsGets or sets the Boolean property value that specifies whether mail accounts that are referenced by mail profiles are included in the generated script.
Propriété publiqueNoMailProfilePrincipalsGets or sets the Boolean property value that specifies whether principals that are referenced by mail profiles are included in the generated script.
Propriété publiqueNonClusteredIndexesGets or sets the Boolean property value that specifies whether non-clustered indexes are included in the generated script.
Propriété publiqueNoTablePartitioningSchemesGets or sets the Boolean property value that specifies whether partition schemes for tables are included in the generated script.
Propriété publiqueNoVardecimalGets or sets an object that specifies whether to include the N clause when you create vardecimal columns in the generated script.
Propriété publiqueNoViewColumnsGets or sets the Boolean property value that specifies whether to include the specified columns for a view.
Propriété publiqueNoXmlNamespacesGets or sets the Boolean property value that specifies whether XML namespaces are included in the generated script.
Propriété publiqueOptimizerDataGets or sets the Boolean property value that specifies whether script optimizer data for the referenced objects are included in the generated script.
Propriété publiquePermissionsGets or sets the Boolean property value that specifies whether to include all permissions in the generated script.
Propriété publiquePrimaryObjectGets or sets the Boolean property value that specifies whether the creation of the referenced object is included in the generated script.
Propriété publiqueSchemaQualifyGets or sets the Boolean property value that specifies whether the schemas associated with objects are included in the generated script.
Propriété publiqueSchemaQualifyForeignKeysReferencesGets or sets the Boolean property value that specifies whether schema-qualified table references for foreign key constraints are included in the generated script.
Propriété publiqueScriptBatchTerminatorGets or sets the ScriptBatchTerminator property value.
Propriété publiqueScriptDataGets or sets the ScriptData property value.
Propriété publiqueScriptDataCompressionGets or sets the Boolean property value that specifies whether to include data compression information in the generated script.
Propriété publiqueScriptDropsGets or sets the Boolean property value that specifies whether the script operation generates a Transact-SQL script to remove the referenced component.
Propriété publiqueScriptOwnerGets or sets the Boolean property value that specifies whether the script owner is included in the generated script.
Propriété publiqueScriptSchemaGets or set the ScriptSchema property value.
Propriété publiqueStatisticsGets or sets the Boolean property value that specifies whether to include statistics for any table or view that is included in the generated script.
Propriété publiqueTargetDatabaseEngineTypeGets or sets the DatabaseEngineType property value.
Propriété publiqueTargetServerVersionGets or sets the version of the instance of SQL Server for which the generated script is intended.
Propriété publiqueTimestampToBinaryGets or sets the Boolean property value that specifies whether to convert timestamp data types to binary(8) data types when scripting the creation of a table or user-defined data type.
Propriété publiqueToFileOnlyGets or sets the Boolean property value that specifies whether to output to file only or to also generate string output.
Propriété publiqueTriggersGets or sets the Boolean property value that specifies whether to include the definition for triggers in the generated script.
Propriété publiqueWithDependenciesGets or sets the Boolean property value that specifies whether to include all dependent objects in the generated script.
Propriété publiqueXmlIndexesGets or sets the Boolean property value that specifies whether XML indexes are included in the generated script.
Haut de la page

  NomDescription
Méthode publiqueAdd(ScriptOption)Adds a ScriptOption object to the ScriptingOptions object.
Méthode publiqueMembre statiqueAdd(ScriptingOptions, ScriptOption)Adds the specified ScriptOption and ScriptingOptions objects to the ScriptingOptions.
Méthode publiqueMembre statiqueConvertVersionConverts the server version to a SqlServerVersion value.
Méthode publiqueEquals (hérité de Object.)
Méthode protégéeFinalize (hérité de Object.)
Méthode publiqueGetHashCode (hérité de Object.)
Méthode publiqueGetType (hérité de Object.)
Méthode protégéeMemberwiseClone (hérité de Object.)
Méthode publiqueRemoveRemoves a ScriptOption object from the ScriptingOptions object.
Méthode publiqueSetTargetDatabaseEngineTypeSets the database engine type as specified in a DatabaseEngineType object.
Méthode publiqueSetTargetServerVersionSets the version of the instance of SQL Server on which the scripting operation is run.
Méthode publiqueMembre statiqueSubtractSubtracts the specified ScriptOption value from the specified ScriptingOptions object.
Méthode publiqueToStringReturns a string that represents the ScriptingOptions object. (remplace Object..::..ToString()()()().)
Haut de la page

  NomDescription
Opérateur publicMembre statiqueAdditionCreates a set of scripting options by performing an addition operation on a ScriptingOptions object and a ScriptOption object.
Opérateur publicMembre statiqueSubtractionCreates a set of scripting options by performing an subtraction operation on a ScriptingOptions object and a ScriptOption object.
Haut de la page

AttentionAttention

Some scripting options cause the Transfer object to generate script that does not execute on the target server.

Thread Safety

Tout membre statique public (Partagé dans Microsoft Visual Basic) de ce type est sûr dans le cadre des opérations à plusieurs threads. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Reference the AdventureWorks2008R2 database.
Dim db As Database
db = srv.Databases("AdventureWorks2008R2")
'Define a Scripter object and set the required scripting options.
Dim scrp As Scripter
scrp = New Scripter(srv)
scrp.Options.ScriptDrops = False
scrp.Options.WithDependencies = True
'Iterate through the tables in database and script each one. Display the script.
'Note that the StringCollection type needs the System.Collections.Specialized namespace to be included.
Dim tb As Table
Dim smoObjects(1) As Urn
For Each tb In db.Tables
    smoObjects = New Urn(0) {}
    smoObjects(0) = tb.Urn
    If tb.IsSystemObject = False Then
        Dim sc As StringCollection
        sc = scrp.Script(smoObjects)
        Dim st As String
        For Each st In sc
            Console.WriteLine(st)
        Next
    End If
Next


PowerShell

$srv = New-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2008R2")
$scrp = New-Object Microsoft.SqlServer.Management.Smo.Scripter($srv)
$scrp.Options.ScriptDrops = $FALSE
$scrp.Options.WithDependencies = $TRUE
$tb = New-Object Microsoft.SqlServer.Management.Smo.Table
#$smoObjects = new-object Microsoft.SqlServer.Management.Smo.Urn[]0
$smoObjects = $tb.Urn
foreach ($tb in $db.Tables)
{
   $smoObjects = $tb.Urn
   if ($tb.IsSystemObject -eq $FALSE)
   {
      $sc = $scrp.Script($smoObjects)
      foreach ($st in $sc)
      {
         Write-Host $st
      }
   }
}

Tous les membres publics static (Shared dans Visual Basic) de ce type sont thread-safe. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

Ajouts de la communauté

AJOUTER
Afficher:
© 2015 Microsoft