Hi All,
I`ve been having a really hard time to acomplish this task. I have a folder where everyday a zipped file is dropped I then want to Unzip the file and map it to my source folder in a SSIS package. I have tried Execute Process task, it runs but nothing happens.
Followd everything mentioned on this post http://www.sql-server-performance.com/2008/ssis-unzip/ , but nothing happens.
executable: C:\Program Files\7-Zip\7z.exe
Arguments: e “S:\Ops\Qt\XS_EV_201603160317.txt” -o+
I also found another way, script task , Followed step by step on here http://sqlblog.com/blogs/jorg_klein/archive/2009/08/27/ssis-unpack-a-zip-file-with-the-script-task.aspx , but failed.
When i try to add the rference as mentioned in the above post, I get an Pop up saying
"No template information found" See the application log in the event viewer, When I checked the event viewer this is what I found " The global template information is out of date. Regenerate the templates by running 'VSTA.exe /installvstemplates' or reinstalling the application. Note: corrective action requires Administrator privileges"
Then I followed everything this Process asked : https://gallery.technet.microsoft.com/Unzipping-with-SSIS-Script-6b055183
See the below Code, Basically I dont have Imports Shell32 Namespace defined.
#Region "Imports" Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Runtime Imports Shell32 #End Region 'ScriptMain is the entry point class of the script. Do not change the name, attributes, 'or parent of this class. <Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()> _<System.CLSCompliantAttribute(False)> _ Partial Public Class ScriptMain Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase #Region "Help: Using Integration Services variables and parameters in a script" 'To use a variable in this script, first ensure that the variable has been added to 'either the list contained in the ReadOnlyVariables property or the list contained in 'the ReadWriteVariables property of this script task, according to whether or not your 'code needs to write to the variable. To add the variable, save this script, close this instance of 'Visual Studio, and update the ReadOnlyVariables and 'ReadWriteVariables properties in the Script Transformation Editor window. 'To use a parameter in this script, follow the same steps. Parameters are always read-only. 'Example of reading from a variable: ' startTime = Dts.Variables("System::StartTime").Value 'Example of writing to a variable: ' Dts.Variables("User::myStringVariable").Value = "new value" 'Example of reading from a package parameter: ' batchId = Dts.Variables("$Package::batchId").Value 'Example of reading from a project parameter: ' batchId = Dts.Variables("$Project::batchId").Value 'Example of reading from a sensitive project parameter: ' batchId = Dts.Variables("$Project::batchId").GetSensitiveValue() #End Region #Region "Help: Firing Integration Services events from a script" 'This script task can fire events for logging purposes. 'Example of firing an error event: ' Dts.Events.FireError(18, "Process Values", "Bad value", "", 0) 'Example of firing an information event: ' Dts.Events.FireInformation(3, "Process Values", "Processing has started", "", 0, fireAgain) 'Example of firing a warning event: ' Dts.Events.FireWarning(14, "Process Values", "No values received for input", "", 0) #End Region #Region "Help: Using Integration Services connection managers in a script" 'Some types of connection managers can be used in this script task. See the topic '"Working with Connection Managers Programatically" for details. 'Example of using an ADO.Net connection manager: ' Dim rawConnection As Object = Dts.Connections("Sales DB").AcquireConnection(Dts.Transaction) ' Dim myADONETConnection As SqlConnection = CType(rawConnection, SqlConnection) ' <Use the connection in some code here, then release the connection> ' Dts.Connections("Sales DB").ReleaseConnection(rawConnection) 'Example of using a File connection manager ' Dim rawConnection As Object = Dts.Connections("Prices.zip").AcquireConnection(Dts.Transaction) ' Dim filePath As String = CType(rawConnection, String) ' <Use the connection in some code here, then release the connection> ' Dts.Connections("Prices.zip").ReleaseConnection(rawConnection) #End Region 'This method is called when this script task executes in the control flow. 'Before returning from this method, set the value of Dts.TaskResult to indicate success or failure. 'To open Help, press F1. Public Sub Main() Try Dim sh As New Shell32.Shell() ' Creating the target directory: IO.Directory.CreateDirectory("C:\Temp\ExtractedFilesFolder") Dim TargetFolder As Shell32.Folder = sh.NameSpace("C:\Target") ' Declaring the inputfile: Dim InputZipFile As Shell32.Folder = sh.NameSpace("C:\Source\F_201512011208.txt.zip") ' Extracting all files from the source file, supressing the progress bar: TargetFolder.CopyHere(InputZipFile.Items, 4) Dts.TaskResult = ScriptResults.Success Catch ex As Exception Dts.Events.FireError(0, "", ex.Message, 0, 0) Dts.TaskResult = ScriptResults.Failure End Try End Sub #Region "ScriptResults declaration" 'This enum provides a convenient shorthand within the scope of this class for setting the 'result of the script. 'This code was generated automatically. Enum ScriptResults Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure End Enum #End Region End Class
I`ve never done this task before , I am very new to it.. Can someone Please help me thru ??
FM