次の方法で共有


ScriptOption クラス

ScriptOption オブジェクトは、ScriptingOptions オブジェクトを使用して設定されるスクリプト作成オプションに含めることができる SQL Server スクリプト オプションを表します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
Public NotInheritable Class ScriptOption
'使用
Dim instance As ScriptOption
public sealed class ScriptOption
public ref class ScriptOption sealed
[<SealedAttribute>]
type ScriptOption =  class end
public final class ScriptOption

説明

ScriptOption オブジェクトは、スクリプトを作成できる各種の SQL Server アイテムのプロパティを格納します。実際にスクリプトを作成するアイテムのセットは、ScriptingOptions オブジェクトを使用して指定します。

警告 : 使用するスクリプト オプションによっては、対象サーバーで実行されないスクリプトが Transfer オブジェクトによって生成されることもあります。

スレッド セーフ

この型の public static (Microsoft Visual Basic では Shared) のすべてのメンバーは、マルチスレッド操作で安全に使用できます。 インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

使用例

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Reference the AdventureWorks database.
Dim db As Database
db = srv.Databases("AdventureWorks")
'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

継承階層

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

スレッド セーフ

この型の public static (Visual Basic では Shared) のメンバーはすべて、スレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。