March 11, 2011 at 8:40 am
I have an ssis package that imports data from text files to sql tables.
However there is also a single line text file that contains a unique value for that 'set' of text files I'm reading in.
I'm struggling with finding a simple way to read this value from a text file into a variable for use elsewhere in the package.
Suggestions?
Bob McC
March 11, 2011 at 9:07 am
You could use a script task to read a line from the file.
using (System.IO.StreamReader rdr = new System.IO.StreamReader(@"C:\Files\out.txt"))
{
Dts.Variables["User::TestString"].Value = rdr.ReadLine();
}
Russel Loski, MCSE Business Intelligence, Data Platform
April 11, 2011 at 3:41 pm
Thanks for all of the help. I ended up doing something like this:
If File.Exists(lstrFileName) Then
' Get the one line that has AS OF DATE
For Each line As String In File.ReadAllLines(lstrFileName)
If line.Contains("AS OF DATE") Then
lstrFileContent = line
End If
Next line
'Look inside the string for the date
Dim lintStart As Integer = InStr(lstrFileContent, "DATE")
'MsgBox("lintStart " & lintStart)
Dim lstrFileAsOfDate As String = lstrFileContent.Substring((lintStart + 11), 8)
Dts.Variables("strFileAsOfDate").Value = lstrFileAsOfDate
'MsgBox("datFileAsOfDate " & Dts.Variables("datFileAsOfDate").Value)
Dts.Variables("blnContinue").Value = True
Else
Dts.Variables("blnContinue").Value = False
End If
October 21, 2011 at 2:48 pm
Since we are bring text into a table, is there a way in SSIS to read a certain column and then a certain row? This would work well for me.
THANKS,
Clark
August 7, 2012 at 2:10 pm
You can read specific row or nth row using Script component. For where clause you have to use condition split.
SSIS: How to read nth Row from Flat File?
Vikash Kumar Singh || www.singhvikash.in
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply