Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Help Read single value from a text file in SSIS Expand / Collapse
Author
Message
Posted Friday, March 11, 2011 8:40 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, July 24, 2014 3:17 PM
Points: 178, Visits: 616
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

Post #1076941
Posted Friday, March 11, 2011 9:07 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Saturday, June 7, 2014 4:22 AM
Points: 565, Visits: 8,703
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, MCITP
Post #1076971
Posted Monday, April 11, 2011 3:41 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, July 2, 2014 3:59 PM
Points: 213, Visits: 572
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
Post #1091797
Posted Friday, October 21, 2011 2:48 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 24, 2012 2:00 PM
Points: 6, Visits: 22
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

Post #1194697
Posted Tuesday, August 7, 2012 2:10 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, June 9, 2014 6:15 AM
Points: 79, Visits: 243
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
Post #1341535
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse