Compartilhar via


Application.SaveToSqlServerAs Método

Definição

Salva um pacote em uma instância do SQL Server com um novo 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)

Parâmetros

package
Package

O pacote a ser salvo.

events
IDTSEvents

O objeto IDTSEvents.

packagePath
String

O caminho e o novo nome a ser atribuído ao pacote. O parâmetro packagePath está no formato \folder\packageName. Se packagePath for especificado sem uma pasta existente, o pacote será salvo com esse parâmetro como seu novo nome.

serverName
String

O nome da instância do SQL Server.

serverUserName
String

O nome de conta usada para fazer logon na instância do SQL Server.

serverPassword
String

A senha da conta do usuário.

Exemplos

O exemplo de código a seguir salva o pacote de exemplo chamado ExecuteProcess.dtsx na pasta msdb , com um novo nome de myNewPackage. Para verificar se o pacote foi salvo, execute a consulta Transact-SQL a seguir no banco de dados msdb . A consulta retorna todos os pacotes armazenados na tabela do sistema msdb .

select * from sysssispackages

Ou conecte-se ao serviço integration services, expanda pacotes armazenados e expanda o MSDB. O pacote com o nome especificado packagePath será listado.

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  

Aplica-se a