Advertisement
paulogp

SSIS: Alterar e retornar variaveis

Jul 13th, 2011
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. /* Exemplo sobre como ler, alterar e retornar variáveis usando o componente Script Task num SSIS */
  2.  
  3.  
  4. using System;
  5. using System.Data;
  6. using Microsoft.SqlServer.Dts.Runtime;
  7. using System.Windows.Forms;
  8.  
  9. namespace ST_c82cf79963ff44c7bae239e77704543a.csproj {
  10.     [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
  11.     public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase {
  12.  
  13.         #region VSTA generated code
  14.         enum ScriptResults
  15.         {
  16.             Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
  17.             Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
  18.         };
  19.         #endregion
  20.  
  21.  
  22.         // USER CODE
  23.         // global vars: ssis_variable; String or Object
  24.         // box: readWriteVariable: User::ssis_variable
  25.         public void Main() {
  26.             // set global ssis variable: ssis_variable
  27.             Dts.Variables["User::ssis_variable"].Value = "hello world";
  28.  
  29.             // get global ssis variable: ssis_variable
  30.             string the_aux_var = Dts.Variables["User::ssis_variable"].Value.ToString();
  31.  
  32.             // message box to "see" the result
  33.             MessageBox.Show(the_aux_var);
  34.  
  35.             // TODO: Add your code here
  36.             Dts.TaskResult = (int)ScriptResults.Success;
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement