2014-04-10 17 views
6

Ho un'attività di script che trasferisce determinati oggetti passati da un server a un altro. Questo è il codiceIl pacchetto SSIS funziona correttamente in Visual Studio ma non riesce quando viene eseguito manualmente sulla casella distribuita

public void Main() 
     { 
      try 
      { 
      string schemaName = Dts.Variables["$Package::SchemaName"].Value.ToString(); 
      string objectName = Dts.Variables["$Package::ObjectName"].Value.ToString(); 

      //object rawETLConnection = Dts.Connections["etl"].AcquireConnection(Dts.Transaction); 
      //Server etlServer = (Server)rawETLConnection; 

      Server etlServer = new Server("ciesqldeva04"); 
      Database etlDB; 
      etlDB = etlServer.Databases["sell_side_content"]; 




      //object rawReportingConnection = Dts.Connections["reporting"].AcquireConnection(Dts.Transaction); 
      //Server reportingServer = (Server)rawReportingConnection; 
      Server reportingServer = new Server("ciesqldeva05"); 





       Transfer xfr; 
       xfr = new Transfer(etlDB); 
       xfr.DestinationServer = reportingServer.Name; 
       xfr.DestinationDatabase = "sell_side_content"; 
       xfr.DropDestinationObjectsFirst = true; 
       xfr.CopyAllObjects = false; 
       xfr.CopyData = true; 
       xfr.CopySchema = true; 
       xfr.Options.DriAll = true; 


       xfr.ObjectList.Add(etlDB.Tables[objectName, schemaName]); 

       xfr.TransferData(); 
      } 
      catch (SmoException smoex) 
      { 
       Dts.Events.FireError(120, " SMO - TransferObjects.dtsx", smoex.Message, "", 0); 

      } 
      catch (Exception ex) 
      { 
       Dts.Events.FireError(120,"Non SMO - TransferObjects.dtsx",ex.Message,"",0); 

      } 
      Dts.TaskResult = (int)ScriptResults.Success; 
     } 

Funziona benissimo quando l'eseguo tramite Visual Studio 2012. Ma quando ho schierarlo sulla scatola ed eseguirlo tramite clic destro sul nome del pacchetto in SQL Server Management Studio e colpire l'esecuzione, si riuscirà con questo messaggio "Trasferisci oggetto usando SMO: Errore: si è verificato un errore durante il trasferimento dei dati. Vedere l'eccezione interna per i dettagli."

Ho anche convertito lo script in un'applicazione di console e l'ho eseguito sulla scatola in cui ho precedentemente distribuito il pacchetto e l'ho eseguito tramite terminale ed è stato in grado di trasferire correttamente così non sembra un problema di DLL mancanti .

Questo è il codice per l'applicazione di console

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Data; 
using Microsoft.SqlServer.Dts.Runtime; 
using Microsoft.SqlServer.Management.Smo; 
using System.Collections.Specialized; 
using System.Collections; 
namespace ConsoleApplication1 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      Server etlServer = new Server("ciesqldeva04"); 
      Database etlDB; 
      etlDB = etlServer.Databases["sell_side_content"]; 




      //object rawReportingConnection = Dts.Connections["reporting"].AcquireConnection(Dts.Transaction); 
      //Server reportingServer = (Server)rawReportingConnection; 
      Server reportingServer = new Server("ciesqldeva05"); 




      try 
      { 
       Transfer xfr; 
       xfr = new Transfer(etlDB); 
       xfr.DestinationServer = reportingServer.Name; 
       xfr.DestinationDatabase = "sell_side_content"; 
       xfr.DropDestinationObjectsFirst = true; 
       xfr.CopyAllObjects = false; 
       xfr.CopyData = true; 
       xfr.CopySchema = true; 
       xfr.Options.DriAll = true; 


       xfr.ObjectList.Add(etlDB.Tables["award_sector", "people"]); 

       xfr.TransferData(); 
      } 
      catch (SmoException smoex) 
      { 
       Console.WriteLine("This is an SMO Exception"); 
       //Display the SMO exception message. 
       Console.WriteLine(smoex.Message); 
       //Display the sequence of non-SMO exceptions that caused the SMO exception. 
      } 
     } 
    } 
} 

Ho provato varie cose, ma senza alcun successo. Qualsiasi aiuto sarebbe molto apprezzato.

P.S. Sto facendo funzionare questo su SQL Server 2012.

+1

Se si cambia il messaggio di log per includere smoex.Inner, puntini si fornisce alcuna informazione per l'errore? Quando esegui questo pacchetto sul server remoto, come lo stai invocando? Sta usando il modello di implementazione del progetto (nuovo) o il modello di distribuzione del pacchetto? – billinkc

+0

Sto utilizzando il modello di distribuzione del progetto. E lo invoco collegandomi a quel server usando SSMS, quindi navigando verso il progetto sotto i cataloghi di servizi di integrazione-> ssisdb -> ... e poi facendo clic con il tasto destro sul pacchetto e premendo il tasto Esegui. – bootkick

+0

Anche fare le odi interne non è di aiuto in quanto l'eccezione che viene registrata non è quella che lancio. Ho la lista degli errori usando questo select message_type, \t messaggio da ssisdb.internal.operation_messages dove operation_id = 74404 \t order by message_time asc – bootkick

risposta

Problemi correlati