Application.SaveToSqlServerAs メソッド

定義

パッケージに新しい名前を付けて SQL Server のインスタンスに保存します。

public:
 void SaveToSqlServerAs(Microsoft::SqlServer::Dts::Runtime::Package ^ package, Microsoft::SqlServer::Dts::Runtime::IDTSEvents ^ events, System::String ^ packagePath, System::String ^ serverName, System::String ^ serverUserName, System::String ^ serverPassword);
public void SaveToSqlServerAs (Microsoft.SqlServer.Dts.Runtime.Package package, Microsoft.SqlServer.Dts.Runtime.IDTSEvents events, string packagePath, string serverName, string serverUserName, string serverPassword);
member this.SaveToSqlServerAs : Microsoft.SqlServer.Dts.Runtime.Package * Microsoft.SqlServer.Dts.Runtime.IDTSEvents * string * string * string * string -> unit
Public Sub SaveToSqlServerAs (package As Package, events As IDTSEvents, packagePath As String, serverName As String, serverUserName As String, serverPassword As String)

パラメーター

package
Package

保存するパッケージです。

events
IDTSEvents

IDTSEvents オブジェクト。

packagePath
String

パッケージに割り当てるパスと新しい名前です。 パラメーター packagePath の形式は \folder\packageName です。 既存のフォルダーを使用しないで packagePath を指定した場合、パッケージは、このパラメーターを新しい名前として使用して保存されます。

serverName
String

SQL Server のインスタンスの名前です。

serverUserName
String

SQL Server のインスタンスにログオンするために使用されるアカウントの名前です。

serverPassword
String

ユーザー アカウントのパスワードです。

次のコード例では、ExecuteProcess.dtsx という名前のサンプル パッケージを、myNewPackage の新しい名前で msdb フォルダーに保存します。 パッケージが保存されたことを確認するには、 msdb データベースに対して次の Transact-SQL クエリを実行します。 このクエリは、 msdb システム テーブルに格納されているすべてのパッケージを返します。

select * from sysssispackages

または、Integration Services サービスに接続し、 格納されているパッケージを展開してから、 MSDB を展開します。 packagePath で指定した名前のパッケージが表示されます。

static void Main(string[] args)  
        {  
           // The variable pkg points to the location  
           // of the ExecuteProcess package sample   
           // that is installed with the SSIS samples.  
            string pkg = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";  

            Application app = new Application();  
            Package p = app.LoadPackage(pkg, null);  

           // Save the package to the SQL Server msdb folder, which is  
           // also the MSDB folder in the Integration Services service, or as a row in the  
           //sysssispackages table.  
            app.SaveToSqlServerAs(p, null, "myNewPackage", "yourserver", null, null);  
        }  
Shared  Sub Main(ByVal args() As String)  
           ' The variable pkg points to the location  
           ' of the ExecuteProcess package sample   
           ' that is installed with the SSIS samples.  
            Dim pkg As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx"   

            Dim app As Application =  New Application()   
            Dim p As Package =  app.LoadPackage(pkg,Nothing)   

           ' Save the package to the SQL Server msdb folder, which is  
           ' also the MSDB folder in the Integration Services service, or as a row in the  
           'sysssispackages table.  
            app.SaveToSqlServerAs(p, Nothing, "myNewPackage", "yourserver", Nothing, Nothing)  
End Sub  

適用対象