SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help Read single value from a text file in SSIS


Help Read single value from a text file in SSIS

Author
Message
BobMcC
BobMcC
Mr or Mrs. 500
Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)Mr or Mrs. 500 (532 reputation)

Group: General Forum Members
Points: 532 Visits: 833
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
Russel Loski
Russel Loski
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1770 Visits: 8907
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
imani_technology
imani_technology
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1764 Visits: 787
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
cdavidson 21612
cdavidson 21612
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 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
Vikash Kumar Singh
Vikash Kumar Singh
SSC Veteran
SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)SSC Veteran (226 reputation)

Group: General Forum Members
Points: 226 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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search