http://sqljunkies.com/WebLog/knight_reign/archive/2005/02/12/7750.aspx
Thanks,
K|||
I setup a ForEach Loop Container to do this.
Create a Package Variable, for example, "varFileName", for the FileName. Then edit the ForEach Loop container. Select "Variable Mappings". Select the drop-down under the "Variable" column and select your "User: varFileName" variable. The index column should read "0". Save the object. Now add a Data Flow task and double-click to edit.
In the Data Flow window, create a Source Script transformation. Define your output columns on the "Inputs and Outputs" option. Click "Script" and add your variable "varFileName" to the property "ReadOnlyVariables". Now click the "Design Script" button, which opens up another window for scripting.
Add "Imports System.IO" to the top so you can read the flat file.
Read the file with the following code:
Dim strRecord as String
Dim objFlatFile As StreamReader = File.OpenText(Variables.varFileName)
Do Until objFlatFile.Peek = -1
strRecord = objFlatFile.ReadLine
[OutputBuffer].AddRow()
[OutputBuffer].[Column1] = Mid$(stRecord,1,4)
... etc.
Loop
Let me know if this helps...
No comments:
Post a Comment