ScriptingOptions ScriptingOptions ScriptingOptions Class

Definition

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

public ref class ScriptingOptions sealed
public sealed class ScriptingOptions
Public NotInheritable Class ScriptingOptions
Inheritance
ScriptingOptionsScriptingOptionsScriptingOptions

Examples

PowerShell

$srv = New-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database  
$db = $srv.Databases.Item("AdventureWorks2012")  
$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  
      }  
   }  
}  

Remarks

Warning

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

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Constructors

ScriptingOptions() ScriptingOptions() ScriptingOptions()

Initializes a new instance of the ScriptingOptions class.

ScriptingOptions(ScriptingOptions) ScriptingOptions(ScriptingOptions) ScriptingOptions(ScriptingOptions)

Initializes a new instance of the ScriptingOptions class based on the specified scripting options.

ScriptingOptions(ScriptOption) ScriptingOptions(ScriptOption) ScriptingOptions(ScriptOption)

Initializes a new instance of the ScriptingOptions class based on the specified ScriptOption object, based on the specified script option.

Properties

AgentAlertJob AgentAlertJob AgentAlertJob

Gets or sets the Boolean property that specifies whether to include SQL Server Agent job name for alert objects in the script.

AgentJobId AgentJobId AgentJobId

Gets or sets the Boolean property that specifies whether to include SQL Server Agent job ID values for alert objects in the script.

AgentNotify AgentNotify AgentNotify

Gets or sets the Boolean property that specifies whether to include notifications for any SQL Server Agent alerts that are in the script.

AllowSystemObjects AllowSystemObjects AllowSystemObjects

Gets or sets the Boolean property that specifies whether system objects can be scripted.

AnsiFile AnsiFile AnsiFile

Gets or sets the Boolean property that specifies whether the script uses multibyte characters and requires code page 1252 to evaluate characters' meaning.

AnsiPadding AnsiPadding AnsiPadding

Gets 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.

AppendToFile AppendToFile AppendToFile

Gets or sets a Boolean property value that specifies whether the script is appended to the end of the output file or overwrites it.

BatchSize BatchSize BatchSize

Gets or sets the number of statements after which to script batch terminator.

Bindings Bindings Bindings

Gets 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.

ChangeTracking ChangeTracking ChangeTracking

Gets or sets whether the ScriptingOptions tracking changes.

ClusteredIndexes ClusteredIndexes ClusteredIndexes

Gets or sets a Boolean property value that specifies whether statements that define clustered indexes are included in the generated script.

ContinueScriptingOnError ContinueScriptingOnError ContinueScriptingOnError

Gets or sets the Boolean property value that specifies whether the scripting operation continues after an error is encountered.

ConvertUserDefinedDataTypesToBaseType ConvertUserDefinedDataTypesToBaseType ConvertUserDefinedDataTypesToBaseType

Gets 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.

DdlBodyOnly DdlBodyOnly DdlBodyOnly

Gets 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.

DdlHeaderOnly DdlHeaderOnly DdlHeaderOnly

Gets 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.

Default Default Default

Gets or sets the Boolean property value that specifies whether the creation of the referenced object is included in the generated script.

DriAll DriAll DriAll

Gets or sets the Boolean property value that specifies whether all DRI objects are included in the generated script.

DriAllConstraints DriAllConstraints DriAllConstraints

Gets or sets the Boolean property value that specifies whether all declarative referential integrity constraints are included in the generated script.

DriAllKeys DriAllKeys DriAllKeys

Gets 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.

DriChecks DriChecks DriChecks

Gets 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.

DriClustered DriClustered DriClustered

Gets 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.

DriDefaults DriDefaults DriDefaults

Gets or sets the Boolean property value that specifies whether dependency relationships defined in defaults with enforced declarative referential integrity are included in the script.

DriForeignKeys DriForeignKeys DriForeignKeys

Gets 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.

DriIncludeSystemNames DriIncludeSystemNames DriIncludeSystemNames

Gets 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.

DriIndexes DriIndexes DriIndexes

Gets 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.

DriNonClustered DriNonClustered DriNonClustered

Gets 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.

DriPrimaryKey DriPrimaryKey DriPrimaryKey

Gets 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.

DriUniqueKeys DriUniqueKeys DriUniqueKeys

Gets 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.

DriWithNoCheck DriWithNoCheck DriWithNoCheck

Gets or sets the Boolean property value that specifies whether the no check statement is included in the script.

Encoding Encoding Encoding

Gets or sets the encoding for the scripting options.

EnforceScriptingOptions EnforceScriptingOptions EnforceScriptingOptions

Gets or sets the Boolean property value that specifies whether the application of all scripting options is enforced for text-based objects, such as SchemaQualify.

ExtendedProperties ExtendedProperties ExtendedProperties

Gets or sets the Boolean property value that specifies whether extended object properties are included in the generated script.

FileName FileName FileName

Gets or sets the name of the file to which the generated script is output.

FullTextCatalogs FullTextCatalogs FullTextCatalogs

Gets or sets the Boolean property value that specifies whether full-text catalogs are included in the generated script.

FullTextIndexes FullTextIndexes FullTextIndexes

Gets or sets the Boolean property value that specifies whether full-text indexes are included in the generated script.

FullTextStopLists FullTextStopLists FullTextStopLists

Gets or sets the Boolean property value that specifies whether full-text stop lists are included in the generated script.

IncludeDatabaseContext IncludeDatabaseContext IncludeDatabaseContext

Gets or sets the Boolean property value that specifies whether database context is included in the generated script.

IncludeDatabaseRoleMemberships IncludeDatabaseRoleMemberships IncludeDatabaseRoleMemberships

Gets or sets a value that indicates whether the database role memberships are included.

IncludeFullTextCatalogRootPath IncludeFullTextCatalogRootPath IncludeFullTextCatalogRootPath

Gets or sets a value that indicates whether the full text catalog root path is included.

IncludeHeaders IncludeHeaders IncludeHeaders

Gets 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.

IncludeIfNotExists IncludeIfNotExists IncludeIfNotExists

Gets or sets a Boolean property value that specifies whether to check the existence of an object before including it in the script.

Indexes Indexes Indexes

Gets or sets the Boolean property value that specifies whether indexes are included in the generated script.

LoginSid LoginSid LoginSid

Gets or sets the Boolean property value that specifies whether the security identifiers are included for any scripted logins in the generated script.

NoAssemblies NoAssemblies NoAssemblies

Gets or sets the Boolean property value that specifies whether assemblies are included in the generated script.

NoCollation NoCollation NoCollation

Gets or sets the Boolean property value that specifies whether to include the collation clause in the generated script.

NoCommandTerminator NoCommandTerminator NoCommandTerminator

Gets or sets the Boolean property value that specifies whether individual Transact-SQL statements are delimited in the generated script.

NoExecuteAs NoExecuteAs NoExecuteAs

Gets 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.

NoFileGroup NoFileGroup NoFileGroup

Gets or sets the Boolean property value that specifies whether to include the 'ON <filegroup>' clause in the generated script.

NoFileStream NoFileStream NoFileStream

Gets or sets an object that specifies whether to include the FILESTREAM_ON clause when you create VarBinaryMax columns in the generated script.

NoFileStreamColumn NoFileStreamColumn NoFileStreamColumn

Gets or sets an object that specifies whether to include the FILESTREAM_ON clause when you create VarBinaryMax columns in the generated script.

NoIdentities NoIdentities NoIdentities

Gets or sets the Boolean property value that specifies whether definitions of identity property seed and increment are included in the generated script.

NoIndexPartitioningSchemes NoIndexPartitioningSchemes NoIndexPartitioningSchemes

Gets or sets the Boolean property value that specifies whether partition schemes for indexes are included in the generated script.

NoMailProfileAccounts NoMailProfileAccounts NoMailProfileAccounts

Gets or sets the Boolean property value that specifies whether mail accounts that are referenced by mail profiles are included in the generated script.

NoMailProfilePrincipals NoMailProfilePrincipals NoMailProfilePrincipals

Gets or sets the Boolean property value that specifies whether principals that are referenced by mail profiles are included in the generated script.

NonClusteredIndexes NonClusteredIndexes NonClusteredIndexes

Gets or sets the Boolean property value that specifies whether non-clustered indexes are included in the generated script.

NoTablePartitioningSchemes NoTablePartitioningSchemes NoTablePartitioningSchemes

Gets or sets the Boolean property value that specifies whether partition schemes for tables are included in the generated script.

NoVardecimal NoVardecimal NoVardecimal

Gets or sets an object that specifies whether to include the N clause when you create vardecimal columns in the generated script.

NoViewColumns NoViewColumns NoViewColumns

Gets or sets the Boolean property value that specifies whether to include the specified columns for a view.

NoXmlNamespaces NoXmlNamespaces NoXmlNamespaces

Gets or sets the Boolean property value that specifies whether XML namespaces are included in the generated script.

OptimizerData OptimizerData OptimizerData

Gets or sets the Boolean property value that specifies whether script optimizer data for the referenced objects are included in the generated script.

Permissions Permissions Permissions

Gets or sets the Boolean property value that specifies whether to include all permissions in the generated script.

PrimaryObject PrimaryObject PrimaryObject

Gets or sets the Boolean property value that specifies whether the creation of the referenced object is included in the generated script.

SchemaQualify SchemaQualify SchemaQualify

Gets or sets the Boolean property value that specifies whether the schemas associated with objects are included in the generated script.

SchemaQualifyForeignKeysReferences SchemaQualifyForeignKeysReferences SchemaQualifyForeignKeysReferences

Gets or sets the Boolean property value that specifies whether schema-qualified table references for foreign key constraints are included in the generated script.

ScriptBatchTerminator ScriptBatchTerminator ScriptBatchTerminator

Gets or sets the ScriptBatchTerminator property value.

ScriptData ScriptData ScriptData

Gets or sets the ScriptData property value.

ScriptDataCompression ScriptDataCompression ScriptDataCompression

Gets or sets the Boolean property value that specifies whether to include data compression information in the generated script.

ScriptDrops ScriptDrops ScriptDrops

Gets or sets the Boolean property value that specifies whether the script operation generates a Transact-SQL script to remove the referenced component.

ScriptOwner ScriptOwner ScriptOwner

Gets or sets the Boolean property value that specifies whether the script owner is included in the generated script.

ScriptSchema ScriptSchema ScriptSchema

Gets or set the ScriptSchema property value.

Statistics Statistics Statistics

Gets or sets the Boolean property value that specifies whether to include statistics for any table or view that is included in the generated script.

TargetDatabaseEngineEdition TargetDatabaseEngineEdition TargetDatabaseEngineEdition

Gets or sets the edition of the target database engine.

TargetDatabaseEngineType TargetDatabaseEngineType TargetDatabaseEngineType

Gets or sets the DatabaseEngineType property value.

TargetServerVersion TargetServerVersion TargetServerVersion

Gets or sets the version of the instance of SQL Server for which the generated script is intended.

TimestampToBinary TimestampToBinary TimestampToBinary

Gets 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.

ToFileOnly ToFileOnly ToFileOnly

Gets or sets the Boolean property value that specifies whether to output to file only or to also generate string output.

Triggers Triggers Triggers

Gets or sets the Boolean property value that specifies whether to include the definition for triggers in the generated script.

WithDependencies WithDependencies WithDependencies

Gets or sets the Boolean property value that specifies whether to include all dependent objects in the generated script.

XmlIndexes XmlIndexes XmlIndexes

Gets or sets the Boolean property value that specifies whether XML indexes are included in the generated script.

Methods

Add(ScriptOption) Add(ScriptOption) Add(ScriptOption)

Adds a ScriptOption object to the ScriptingOptions object.

Add(ScriptingOptions, ScriptOption) Add(ScriptingOptions, ScriptOption) Add(ScriptingOptions, ScriptOption)

Adds the specified ScriptOption and ScriptingOptions objects to the ScriptingOptions.

ConvertVersion(Version) ConvertVersion(Version) ConvertVersion(Version)

Converts the server version to a SqlServerVersion value.

Remove(ScriptOption) Remove(ScriptOption) Remove(ScriptOption)

Removes a ScriptOption object from the ScriptingOptions object.

SetTargetDatabaseEngineType(DatabaseEngineType) SetTargetDatabaseEngineType(DatabaseEngineType) SetTargetDatabaseEngineType(DatabaseEngineType)

Sets the database engine type as specified in a Microsoft.SqlServer.Management.Common.DatabaseEngineType object.

SetTargetServerVersion(ServerVersion) SetTargetServerVersion(ServerVersion) SetTargetServerVersion(ServerVersion)

Sets the version of the instance of SQL Server on which the scripting operation is run.

Subtract(ScriptingOptions, ScriptOption) Subtract(ScriptingOptions, ScriptOption) Subtract(ScriptingOptions, ScriptOption)

Subtracts the specified ScriptOption value from the specified ScriptingOptions object.

ToString() ToString() ToString()

Returns a string that represents the ScriptingOptions object.

Operators

Addition(ScriptingOptions, ScriptOption) Addition(ScriptingOptions, ScriptOption) Addition(ScriptingOptions, ScriptOption)

Creates a set of scripting options by performing an addition operation on a ScriptingOptions object and a ScriptOption object.

Subtraction(ScriptingOptions, ScriptOption) Subtraction(ScriptingOptions, ScriptOption) Subtraction(ScriptingOptions, ScriptOption)

Creates a set of scripting options by performing an subtraction operation on a ScriptingOptions object and a ScriptOption object.

Applies to