Application.SaveToSqlServerAs Méthode

Définition

Enregistre un package dans une instance de SQL Server sous un nouveau nom.

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)

Paramètres

package
Package

Package à enregistrer.

events
IDTSEvents

Objet IDTSEvents.

packagePath
String

Chemin d'accès et nouveau nom à attribuer au package. Le paramètre packagePath est au format \folder\packageName. Si packagePath est spécifié en omettant le nom du dossier, le package est enregistré avec ce paramètre sous son nouveau nom.

serverName
String

Nom de l'instance de SQL Server.

serverUserName
String

Nom du compte utilisé pour se connecter à l'instance de SQL Server.

serverPassword
String

Mot de passe du compte d'utilisateur.

Exemples

L’exemple de code suivant enregistre l’exemple de package nommé ExecuteProcess.dtsx dans le dossier msdb , avec un nouveau nom de myNewPackage. Pour vérifier que le package a été enregistré, exécutez la requête Transact-SQL suivante sur la base de données msdb . La requête retourne tous les packages stockés dans la table système msdb .

select * from sysssispackages

Vous pouvez également vous connecter au service Integration Services, développer des packages stockés, puis développer MSDB. Le package portant le nom spécifié packagePath est répertorié.

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  

S’applique à