Linguaggio

Application.SaveToSqlServerAs Metodo

Definizione

Salva un pacchetto su un'istanza di SQL Server con un nuovo nome.

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)

Parametri

package
Package

Il pacco da salvare.

events
IDTSEvents

Oggetto IDTSEvents.

packagePath
String

Il percorso e il nuovo nome da assegnare al pacchetto. Il parametro packagePath è nel formato \folder\Namepackage. Se packagePath è specificato senza una cartella esistente, il pacchetto verrà salvato con questo parametro come nuovo nome.

serverName
String

Nome dell'istanza di SQL Server.

serverUserName
String

Il nome dell'account usato per accedere all'istanza di SQL Server.

serverPassword
String

La password dell'account utente.

Esempio

Il seguente esempio di codice salva il pacchetto di esempio chiamato ExecuteProcess.dtsx nella cartella msdb , con un nuovo nome myNewPackage. Per verificare che il pacchetto sia stato salvato, esegui la seguente Transact-SQL query sul database msdb . La query restituisce tutti i pacchetti memorizzati nella tabella di sistema msdb .

select * from sysssispackages

Oppure, collegarsi al servizio Integration Services, espandere i Pacchetti Memorizzati e poi espandere MSDB. Il pacchetto con il nome specificato in packagePath sarà elencato.

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  

Si applica a