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: Monday, March 31, 2014 1:29 PM
Points: 177, Visits: 589
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: Today @ 2:37 PM
Points: 563, Visits: 8,639
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-Enthusiastic

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

Group: General Forum Members
Last Login: Thursday, October 17, 2013 4:44 PM
Points: 193, Visits: 513
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 07, 2012 2:10 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 07, 2014 2:09 PM
Points: 79, Visits: 242
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