Application.SaveToSqlServerAs Método

Definición

Guarda un paquete en una instancia de SQL Server con un nuevo nombre.

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)

Parámetros

package
Package

El paquete que se va a guardar.

events
IDTSEvents

Objeto IDTSEvents.

packagePath
String

La ruta y el nuevo nombre que se van a asignar al paquete. El parámetro packagePath tiene el formato \folder\packageName. Si packagePath se especifica sin una carpeta existente, el paquete se guardará con este parámetro como su nuevo nombre.

serverName
String

Nombre de la instancia de SQL Server.

serverUserName
String

Nombre de la cuenta usada para iniciar sesión en la instancia de SQL Server.

serverPassword
String

La contraseña de la cuenta de usuario.

Ejemplos

En el ejemplo de código siguiente se guarda el paquete de ejemplo denominado ExecuteProcess.dtsx en la carpeta msdb , con un nuevo nombre de myNewPackage. Para comprobar que el paquete se guardó, ejecute la siguiente consulta de Transact-SQL en la base de datos msdb . La consulta devuelve todos los paquetes almacenados en la tabla del sistema msdb .

select * from sysssispackages

O bien, conéctese al servicio Integration Services, expanda Paquetes almacenados y, a continuación, expanda MSDB. Se mostrará el paquete con el nombre especificado en 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  

Se aplica a